Skip to content

Commit a4a606c

Browse files
committed
fix: Do not use the native parser in Safari and Node.js 4
It does not return the offset of the error occurrence, which would not allow adding the context information to the thrown error.
1 parent 03561ec commit a4a606c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/configurable-parser.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@ function restoreContext (changed) {
3939
}
4040
}
4141

42+
var isSafari = typeof navigator !== 'undefined' && /Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor)
43+
var oldNode = typeof process !== 'undefined' && process.version.startsWith('v4.')
44+
4245
function needsCustomParser () {
4346
return this.ignoreComments || this.allowSingleQuotedStrings ||
44-
this.mode === 'cjson' || this.mode === 'json5'
47+
this.mode === 'cjson' || this.mode === 'json5' || isSafari || oldNode
4548
}
4649

4750
function getReviver (options) {

0 commit comments

Comments
 (0)