Created
July 22, 2021 16:04
-
-
Save webarthur/526bf193a3d701faa9722f8faf97442a to your computer and use it in GitHub Desktop.
Fix OFX unclosed tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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