File tree 2 files changed +6
-5
lines changed
2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
- const parser = require ( 'fast-xml-parser' ) ;
2
+ const { XMLParser , XMLValidator } = require ( 'fast-xml-parser' ) ;
3
3
4
4
const isSvg = input => {
5
5
if ( input === undefined || input === null ) {
6
6
return false ;
7
7
}
8
8
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 ( ) ;
11
10
12
11
if ( input . length === 0 ) {
13
12
return false ;
14
13
}
15
14
16
15
// 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 ) {
18
17
return false ;
19
18
}
20
19
21
20
let jsonObject ;
21
+ const parser = new XMLParser ( ) ;
22
+
22
23
try {
23
24
jsonObject = parser . parse ( input ) ;
24
25
} catch ( _ ) {
Original file line number Diff line number Diff line change 37
37
" buffer"
38
38
],
39
39
"dependencies" : {
40
- "fast-xml-parser" : " ^3.19.0 "
40
+ "fast-xml-parser" : " ^4.1.3 "
41
41
},
42
42
"devDependencies" : {
43
43
"@types/node" : " ^11.13.0" ,
You can’t perform that action at this time.
0 commit comments