Skip to content

Commit

Permalink
upgrade to fast-xml-parser 4.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
gartcimore committed Feb 27, 2023
1 parent d01521d commit 7ec2574
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 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
4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "is-svg",
"version": "4.3.2",
"version": "4.3.3",
"description": "Check if a string or buffer is SVG",
"license": "MIT",
"repository": "sindresorhus/is-svg",
Expand Down 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 7ec2574

Please sign in to comment.