Skip to content

Commit

Permalink
Update fast-xml-parser dependency (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
gartcimore committed Feb 28, 2023
1 parent d01521d commit 98725ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions index.js
@@ -1,24 +1,25 @@
'use strict';
const parser = require('fast-xml-parser');
const {XMLParser, XMLValidator} = require('fast-xml-parser');

const isSvg = input => {
if (input === undefined || input === null) {
return false;
}

// TODO: Remove the `.replace` call when using `fast-xml-parser@4` which has fixed the bug.
input = input.toString().trim().replace(/\n/g, ' ');
input = input.toString().trim();

if (input.length === 0) {
return false;
}

// Has to be `!==` as it can also return an object with error info.
if (parser.validate(input) !== true) {
if (XMLValidator.validate(input) !== true) {
return false;
}

let jsonObject;
const parser = new XMLParser();

try {
jsonObject = parser.parse(input);
} catch (_) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -37,7 +37,7 @@
"buffer"
],
"dependencies": {
"fast-xml-parser": "^3.19.0"
"fast-xml-parser": "^4.1.3"
},
"devDependencies": {
"@types/node": "^11.13.0",
Expand Down

0 comments on commit 98725ee

Please sign in to comment.