@@ -5,14 +5,22 @@ 'use strict'; | ||
const internals = { | ||
suspectRx: /"(?:_|\\u005f)(?:_|\\u005f)(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006f)(?:t|\\u0074)(?:o|\\u006f)(?:_|\\u005f)(?:_|\\u005f)"/ | ||
suspectRx: /"(?:_|\\u005f)(?:_|\\u005f)(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006f)(?:t|\\u0074)(?:o|\\u006f)(?:_|\\u005f)(?:_|\\u005f)"\s*\:/ | ||
}; | ||
exports.parse = function (text, ...args) { | ||
exports.parse = function (text, reviver, options) { | ||
// Normalize arguments | ||
const firstOptions = typeof args[0] === 'object' && args[0]; | ||
const reviver = args.length > 1 || !firstOptions ? args[0] : undefined; | ||
const options = (args.length > 1 && args[1]) || firstOptions || {}; | ||
if (!options) { | ||
if (reviver && | ||
typeof reviver === 'object') { | ||
options = reviver; | ||
reviver = undefined; | ||
} | ||
else { | ||
options = {}; | ||
} | ||
} | ||
// Parse normally, allowing exceptions | ||
@@ -50,4 +58,6 @@ | ||
exports.scan = function (obj, options = {}) { | ||
exports.scan = function (obj, options) { | ||
options = options || {}; | ||
let next = [obj]; | ||
@@ -54,0 +64,0 @@ |
{ | ||
"name": "bourne", | ||
"description": "JSON parse with prototype poisoning protection", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"repository": "git://github.com/hapijs/bourne", | ||
@@ -6,0 +6,0 @@ "main": "lib/index.js", |
5398
0.82%58
16%