Skip to content

Instantly share code, notes, and snippets.

@webarthur
Created July 22, 2021 16:04
Show Gist options
  • Save webarthur/526bf193a3d701faa9722f8faf97442a to your computer and use it in GitHub Desktop.
Save webarthur/526bf193a3d701faa9722f8faf97442a to your computer and use it in GitHub Desktop.
Fix OFX unclosed tags
function fixOfxData (ofx) {
const lines = ofxData.split(/[\n\r]/)
const reUnclosedTag = /(^[^<]*<(.+)>[^>]+$)/
// Fix unclosed tags line by line
for (var i=0; i<lines.length; i++) {
if (reUnclosedTag.test(lines[i].trim())) {
lines[i] = lines[i].replace(reUnclosedTag, '$1</$2>')
}
}
return lines.join('\n')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment