summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/request/node_modules/qs/lib/parse.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/request/node_modules/qs/lib/parse.js')
-rw-r--r--[-rwxr-xr-x]deps/npm/node_modules/request/node_modules/qs/lib/parse.js27
1 files changed, 14 insertions, 13 deletions
diff --git a/deps/npm/node_modules/request/node_modules/qs/lib/parse.js b/deps/npm/node_modules/request/node_modules/qs/lib/parse.js
index 97387a6a26..1307e9d797 100755..100644
--- a/deps/npm/node_modules/request/node_modules/qs/lib/parse.js
+++ b/deps/npm/node_modules/request/node_modules/qs/lib/parse.js
@@ -16,7 +16,7 @@ var defaults = {
strictNullHandling: false
};
-var parseValues = function parseValues(str, options) {
+var parseValues = function parseQueryStringValues(str, options) {
var obj = {};
var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);
@@ -42,7 +42,7 @@ var parseValues = function parseValues(str, options) {
return obj;
};
-var parseObject = function parseObject(chain, val, options) {
+var parseObject = function parseObjectRecursive(chain, val, options) {
if (!chain.length) {
return val;
}
@@ -55,7 +55,7 @@ var parseObject = function parseObject(chain, val, options) {
obj = obj.concat(parseObject(chain, val, options));
} else {
obj = options.plainObjects ? Object.create(null) : {};
- var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root;
+ var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
var index = parseInt(cleanRoot, 10);
if (
!isNaN(index) &&
@@ -74,36 +74,37 @@ var parseObject = function parseObject(chain, val, options) {
return obj;
};
-var parseKeys = function parseKeys(givenKey, val, options) {
+var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
if (!givenKey) {
return;
}
// Transform dot notation to bracket notation
- var key = options.allowDots ? givenKey.replace(/\.([^\.\[]+)/g, '[$1]') : givenKey;
+ var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
// The regex chunks
- var parent = /^([^\[\]]*)/;
- var child = /(\[[^\[\]]*\])/g;
+ var brackets = /(\[[^[\]]*])/;
+ var child = /(\[[^[\]]*])/g;
// Get the parent
- var segment = parent.exec(key);
+ var segment = brackets.exec(key);
+ var parent = segment ? key.slice(0, segment.index) : key;
// Stash the parent if it exists
var keys = [];
- if (segment[1]) {
+ if (parent) {
// If we aren't using plain objects, optionally prefix keys
// that would overwrite object prototype properties
- if (!options.plainObjects && has.call(Object.prototype, segment[1])) {
+ if (!options.plainObjects && has.call(Object.prototype, parent)) {
if (!options.allowPrototypes) {
return;
}
}
- keys.push(segment[1]);
+ keys.push(parent);
}
// Loop through children appending to the array until we hit depth
@@ -111,9 +112,9 @@ var parseKeys = function parseKeys(givenKey, val, options) {
var i = 0;
while ((segment = child.exec(key)) !== null && i < options.depth) {
i += 1;
- if (!options.plainObjects && has.call(Object.prototype, segment[1].replace(/\[|\]/g, ''))) {
+ if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
if (!options.allowPrototypes) {
- continue;
+ return;
}
}
keys.push(segment[1]);