euforic / banking.js

The Missing API for Banks - Get all of your transactions and balances using node

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'&' in ofx file cause error, replace before parse in ofx.js file

Davidsonc opened this issue · comments

new code:
data.xml = ofx
// Remove empty spaces and line breaks between tags
.replace(/>\s+</g, '><')
// Remove empty spaces and line breaks before tags content
.replace(/\s+</g, '<')
// Remove empty spaces and line breaks after tags content
.replace(/>\s+/g, '>')
// Remove dots in start-tags names and remove end-tags with dots
.replace(/<([A-Z0-9_])+.+([A-Z0-9_])>([^<]+)(</\1.\2>)?/g, '<$1$2>$3')
// Add a new end-tags for the ofx elements
.replace(/<(\w+?)>([^<]+)/g, '<$1>$2</$1>')
// Remove duplicate end-tags
.replace(/</(\w+?)>(</\1>)?/g, '</$1>')
// replace '&' por 'e'
//######################################
.replace(/&/g, 'e');
;

feel free to put in a PR