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 486146b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -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 All @@ -36,6 +37,7 @@ const isSvg = input => {
return true;
};


module.exports = isSvg;
// TODO: Remove this for the next major release
module.exports.default = isSvg;
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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 486146b

Please sign in to comment.