Skip to content

Commit

Permalink
fix: Do not use the native parser in Safari and Node.js 4
Browse files Browse the repository at this point in the history
It does not return the offset of the error occurrence, which would not allow adding the context information to the thrown error.
  • Loading branch information
prantlf committed Jun 2, 2019
1 parent 03561ec commit a4a606c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/configurable-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ function restoreContext (changed) {
}
}

var isSafari = typeof navigator !== 'undefined' && /Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor)
var oldNode = typeof process !== 'undefined' && process.version.startsWith('v4.')

function needsCustomParser () {
return this.ignoreComments || this.allowSingleQuotedStrings ||
this.mode === 'cjson' || this.mode === 'json5'
this.mode === 'cjson' || this.mode === 'json5' || isSafari || oldNode
}

function getReviver (options) {
Expand Down

0 comments on commit a4a606c

Please sign in to comment.