Skip to content

Commit 98725ee

Browse files
authoredFeb 28, 2023
Update fast-xml-parser dependency (#35)
1 parent d01521d commit 98725ee

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed
 

‎index.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
'use strict';
2-
const parser = require('fast-xml-parser');
2+
const {XMLParser, XMLValidator} = require('fast-xml-parser');
33

44
const isSvg = input => {
55
if (input === undefined || input === null) {
66
return false;
77
}
88

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

1211
if (input.length === 0) {
1312
return false;
1413
}
1514

1615
// Has to be `!==` as it can also return an object with error info.
17-
if (parser.validate(input) !== true) {
16+
if (XMLValidator.validate(input) !== true) {
1817
return false;
1918
}
2019

2120
let jsonObject;
21+
const parser = new XMLParser();
22+
2223
try {
2324
jsonObject = parser.parse(input);
2425
} catch (_) {

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"buffer"
3838
],
3939
"dependencies": {
40-
"fast-xml-parser": "^3.19.0"
40+
"fast-xml-parser": "^4.1.3"
4141
},
4242
"devDependencies": {
4343
"@types/node": "^11.13.0",

0 commit comments

Comments
 (0)
Please sign in to comment.