aboutsummaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/request/node_modules/qs
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/request/node_modules/qs')
-rw-r--r--deps/npm/node_modules/request/node_modules/qs/.editorconfig30
-rw-r--r--deps/npm/node_modules/request/node_modules/qs/.jscs.json175
-rw-r--r--deps/npm/node_modules/request/node_modules/qs/CHANGELOG.md46
-rw-r--r--deps/npm/node_modules/request/node_modules/qs/README.md117
-rw-r--r--deps/npm/node_modules/request/node_modules/qs/dist/qs.js182
-rw-r--r--deps/npm/node_modules/request/node_modules/qs/lib/parse.js67
-rw-r--r--deps/npm/node_modules/request/node_modules/qs/lib/stringify.js15
-rw-r--r--deps/npm/node_modules/request/node_modules/qs/lib/utils.js106
-rw-r--r--deps/npm/node_modules/request/node_modules/qs/package.json40
-rw-r--r--deps/npm/node_modules/request/node_modules/qs/test/parse.js56
-rw-r--r--deps/npm/node_modules/request/node_modules/qs/test/stringify.js35
-rw-r--r--deps/npm/node_modules/request/node_modules/qs/test/utils.js12
12 files changed, 485 insertions, 396 deletions
diff --git a/deps/npm/node_modules/request/node_modules/qs/.editorconfig b/deps/npm/node_modules/request/node_modules/qs/.editorconfig
new file mode 100644
index 0000000000..b2654e7ac5
--- /dev/null
+++ b/deps/npm/node_modules/request/node_modules/qs/.editorconfig
@@ -0,0 +1,30 @@
+root = true
+
+[*]
+indent_style = space
+indent_size = 4
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+max_line_length = 140
+
+[test/*]
+max_line_length = off
+
+[*.md]
+max_line_length = off
+
+[*.json]
+max_line_length = off
+
+[Makefile]
+max_line_length = off
+
+[CHANGELOG.md]
+indent_style = space
+indent_size = 2
+
+[LICENSE]
+indent_size = 2
+max_line_length = off
diff --git a/deps/npm/node_modules/request/node_modules/qs/.jscs.json b/deps/npm/node_modules/request/node_modules/qs/.jscs.json
deleted file mode 100644
index 7296cbab09..0000000000
--- a/deps/npm/node_modules/request/node_modules/qs/.jscs.json
+++ /dev/null
@@ -1,175 +0,0 @@
-{
- "es3": true,
-
- "additionalRules": [],
-
- "requireSemicolons": true,
-
- "disallowMultipleSpaces": true,
-
- "disallowIdentifierNames": [],
-
- "requireCurlyBraces": {
- "allExcept": [],
- "keywords": ["if", "else", "for", "while", "do", "try", "catch"]
- },
-
- "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"],
-
- "disallowSpaceAfterKeywords": [],
-
- "disallowSpaceBeforeComma": true,
- "disallowSpaceAfterComma": false,
- "disallowSpaceBeforeSemicolon": true,
-
- "disallowNodeTypes": [
- "DebuggerStatement",
- "ForInStatement",
- "LabeledStatement",
- "SwitchCase",
- "SwitchStatement",
- "WithStatement"
- ],
-
- "requireObjectKeysOnNewLine": { "allExcept": ["sameLine"] },
-
- "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true },
- "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true },
- "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true },
- "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true },
- "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true },
-
- "requireSpaceBetweenArguments": true,
-
- "disallowSpacesInsideParentheses": true,
-
- "disallowSpacesInsideArrayBrackets": true,
-
- "disallowQuotedKeysInObjects": { "allExcept": ["reserved"] },
-
- "disallowSpaceAfterObjectKeys": true,
-
- "requireCommaBeforeLineBreak": true,
-
- "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
- "requireSpaceAfterPrefixUnaryOperators": [],
-
- "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
- "requireSpaceBeforePostfixUnaryOperators": [],
-
- "disallowSpaceBeforeBinaryOperators": [],
- "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
-
- "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
- "disallowSpaceAfterBinaryOperators": [],
-
- "disallowImplicitTypeConversion": ["binary", "string"],
-
- "disallowKeywords": ["with", "eval"],
-
- "requireKeywordsOnNewLine": [],
- "disallowKeywordsOnNewLine": ["else"],
-
- "requireLineFeedAtFileEnd": true,
-
- "disallowTrailingWhitespace": true,
-
- "disallowTrailingComma": true,
-
- "excludeFiles": ["node_modules/**", "vendor/**"],
-
- "disallowMultipleLineStrings": true,
-
- "requireDotNotation": { "allExcept": ["keywords"] },
-
- "requireParenthesesAroundIIFE": true,
-
- "validateLineBreaks": "LF",
-
- "validateQuoteMarks": {
- "escape": true,
- "mark": "'"
- },
-
- "disallowOperatorBeforeLineBreak": [],
-
- "requireSpaceBeforeKeywords": [
- "do",
- "for",
- "if",
- "else",
- "switch",
- "case",
- "try",
- "catch",
- "finally",
- "while",
- "with",
- "return"
- ],
-
- "validateAlignedFunctionParameters": {
- "lineBreakAfterOpeningBraces": true,
- "lineBreakBeforeClosingBraces": true
- },
-
- "requirePaddingNewLinesBeforeExport": true,
-
- "validateNewlineAfterArrayElements": {
- "maximum": 1
- },
-
- "requirePaddingNewLinesAfterUseStrict": true,
-
- "disallowArrowFunctions": true,
-
- "disallowMultiLineTernary": true,
-
- "validateOrderInObjectKeys": "asc-insensitive",
-
- "disallowIdenticalDestructuringNames": true,
-
- "disallowNestedTernaries": { "maxLevel": 1 },
-
- "requireSpaceAfterComma": { "allExcept": ["trailing"] },
- "requireAlignedMultilineParams": false,
-
- "requireSpacesInGenerator": {
- "afterStar": true
- },
-
- "disallowSpacesInGenerator": {
- "beforeStar": true
- },
-
- "disallowVar": false,
-
- "requireArrayDestructuring": false,
-
- "requireEnhancedObjectLiterals": false,
-
- "requireObjectDestructuring": false,
-
- "requireEarlyReturn": false,
-
- "requireCapitalizedConstructorsNew": {
- "allExcept": ["Function", "String", "Object", "Symbol", "Number", "Date", "RegExp", "Error", "Boolean", "Array"]
- },
-
- "requireImportAlphabetized": false,
-
- "requireSpaceBeforeObjectValues": true,
- "requireSpaceBeforeDestructuredValues": true,
-
- "disallowSpacesInsideTemplateStringPlaceholders": true,
-
- "disallowArrayDestructuringReturn": false,
-
- "requireNewlineBeforeSingleStatementsInIf": false,
-
- "disallowUnusedVariables": true,
-
- "requireSpacesInsideImportedObjectBraces": true,
-
- "requireUseStrict": true
-}
diff --git a/deps/npm/node_modules/request/node_modules/qs/CHANGELOG.md b/deps/npm/node_modules/request/node_modules/qs/CHANGELOG.md
index 85e69b0a22..71d5a3e8f9 100644
--- a/deps/npm/node_modules/request/node_modules/qs/CHANGELOG.md
+++ b/deps/npm/node_modules/request/node_modules/qs/CHANGELOG.md
@@ -1,3 +1,24 @@
+## **6.5.1**
+- [Fix] Fix parsing & compacting very deep objects (#224)
+- [Refactor] name utils functions
+- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape`
+- [Tests] up to `node` `v8.4`; use `nvm install-latest-npm` so newer npm doesn’t break older node
+- [Tests] Use precise dist for Node.js 0.6 runtime (#225)
+- [Tests] make 0.6 required, now that it’s passing
+- [Tests] on `node` `v8.2`; fix npm on node 0.6
+
+## **6.5.0**
+- [New] add `utils.assign`
+- [New] pass default encoder/decoder to custom encoder/decoder functions (#206)
+- [New] `parse`/`stringify`: add `ignoreQueryPrefix`/`addQueryPrefix` options, respectively (#213)
+- [Fix] Handle stringifying empty objects with addQueryPrefix (#217)
+- [Fix] do not mutate `options` argument (#207)
+- [Refactor] `parse`: cache index to reuse in else statement (#182)
+- [Docs] add various badges to readme (#208)
+- [Dev Deps] update `eslint`, `browserify`, `iconv-lite`, `tape`
+- [Tests] up to `node` `v8.1`, `v7.10`, `v6.11`; npm v4.6 breaks on node < v1; npm v5+ breaks on node < v4
+- [Tests] add `editorconfig-tools`
+
## **6.4.0**
- [New] `qs.stringify`: add `encodeValuesOnly` option
- [Fix] follow `allowPrototypes` option during merge (#201, #201)
@@ -7,6 +28,13 @@
- [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
- [eslint] reduce warnings
+## **6.3.2**
+- [Fix] follow `allowPrototypes` option during merge (#201, #200)
+- [Dev Deps] update `eslint`
+- [Fix] chmod a-x
+- [Fix] support keys starting with brackets (#202, #200)
+- [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
+
## **6.3.1**
- [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties (thanks, @snyk!)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `browserify`, `iconv-lite`, `qs-iconv`, `tape`
@@ -33,6 +61,12 @@
- [Tests] skip Object.create tests when null objects are not available
- [Tests] Turn on eslint for test files (#175)
+## **6.2.3**
+- [Fix] follow `allowPrototypes` option during merge (#201, #200)
+- [Fix] chmod a-x
+- [Fix] support keys starting with brackets (#202, #200)
+- [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
+
## **6.2.2**
- [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties
@@ -48,6 +82,12 @@
- [New] add "encoder" and "decoder" options, for custom param encoding/decoding (#160)
- [Fix] fix compacting of nested sparse arrays (#150)
+## **6.1.2
+- [Fix] follow `allowPrototypes` option during merge (#201, #200)
+- [Fix] chmod a-x
+- [Fix] support keys starting with brackets (#202, #200)
+- [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
+
## **6.1.1**
- [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties
@@ -56,6 +96,12 @@
- [Fix] "sort" option should work at a depth of 3 or more (#151)
- [Fix] Restore `dist` directory; will be removed in v7 (#148)
+## **6.0.4**
+- [Fix] follow `allowPrototypes` option during merge (#201, #200)
+- [Fix] chmod a-x
+- [Fix] support keys starting with brackets (#202, #200)
+- [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
+
## **6.0.3**
- [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties
- [Fix] Restore `dist` directory; will be removed in v7 (#148)
diff --git a/deps/npm/node_modules/request/node_modules/qs/README.md b/deps/npm/node_modules/request/node_modules/qs/README.md
index 32fc3123fe..d81196662b 100644
--- a/deps/npm/node_modules/request/node_modules/qs/README.md
+++ b/deps/npm/node_modules/request/node_modules/qs/README.md
@@ -1,8 +1,14 @@
-# qs
+# qs <sup>[![Version Badge][2]][1]</sup>
-A querystring parsing and stringifying library with some added security.
+[![Build Status][3]][4]
+[![dependency status][5]][6]
+[![dev dependency status][7]][8]
+[![License][license-image]][license-url]
+[![Downloads][downloads-image]][downloads-url]
+
+[![npm badge][11]][1]
-[![Build Status](https://api.travis-ci.org/ljharb/qs.svg)](http://travis-ci.org/ljharb/qs)
+A querystring parsing and stringifying library with some added security.
Lead Maintainer: [Jordan Harband](https://github.com/ljharb)
@@ -33,9 +39,9 @@ For example, the string `'foo[bar]=baz'` converts to:
```javascript
assert.deepEqual(qs.parse('foo[bar]=baz'), {
- foo: {
- bar: 'baz'
- }
+ foo: {
+ bar: 'baz'
+ }
});
```
@@ -57,7 +63,7 @@ URI encoded strings work too:
```javascript
assert.deepEqual(qs.parse('a%5Bb%5D=c'), {
- a: { b: 'c' }
+ a: { b: 'c' }
});
```
@@ -65,11 +71,11 @@ You can also nest your objects, like `'foo[bar][baz]=foobarbaz'`:
```javascript
assert.deepEqual(qs.parse('foo[bar][baz]=foobarbaz'), {
- foo: {
- bar: {
- baz: 'foobarbaz'
+ foo: {
+ bar: {
+ baz: 'foobarbaz'
+ }
}
- }
});
```
@@ -78,19 +84,19 @@ By default, when nesting objects **qs** will only parse up to 5 children deep. T
```javascript
var expected = {
- a: {
- b: {
- c: {
- d: {
- e: {
- f: {
- '[g][h][i]': 'j'
+ a: {
+ b: {
+ c: {
+ d: {
+ e: {
+ f: {
+ '[g][h][i]': 'j'
+ }
+ }
+ }
}
- }
}
- }
}
- }
};
var string = 'a[b][c][d][e][f][g][h][i]=j';
assert.deepEqual(qs.parse(string), expected);
@@ -112,6 +118,13 @@ var limited = qs.parse('a=b&c=d', { parameterLimit: 1 });
assert.deepEqual(limited, { a: 'b' });
```
+To bypass the leading question mark, use `ignoreQueryPrefix`:
+
+```javascript
+var prefixed = qs.parse('?a=b&c=d', { ignoreQueryPrefix: true });
+assert.deepEqual(prefixed, { a: 'b', c: 'd' });
+```
+
An optional delimiter can also be passed:
```javascript
@@ -227,10 +240,10 @@ assert.equal(unencoded, 'a[b]=c');
Encoding can be disabled for keys by setting the `encodeValuesOnly` option to `true`:
```javascript
-var encodedValues = qs.stringify(
- { a: 'b', c: ['d', 'e=f'], f: [['g'], ['h']] },
- { encodeValuesOnly: true }
-)
+var encodedValues = qs.stringify(
+ { a: 'b', c: ['d', 'e=f'], f: [['g'], ['h']] },
+ { encodeValuesOnly: true }
+);
assert.equal(encodedValues,'a=b&c[0]=d&c[1]=e%3Df&f[0][0]=g&f[1][0]=h');
```
@@ -238,8 +251,8 @@ This encoding can also be replaced by a custom encoding method set as `encoder`
```javascript
var encoded = qs.stringify({ a: { b: 'c' } }, { encoder: function (str) {
- // Passed in values `a`, `b`, `c`
- return // Return encoded string
+ // Passed in values `a`, `b`, `c`
+ return // Return encoded string
}})
```
@@ -249,8 +262,8 @@ Analogue to the `encoder` there is a `decoder` option for `parse` to override de
```javascript
var decoded = qs.parse('x=z', { decoder: function (str) {
- // Passed in values `x`, `z`
- return // Return decoded string
+ // Passed in values `x`, `z`
+ return // Return decoded string
}})
```
@@ -317,6 +330,12 @@ Properties that are set to `undefined` will be omitted entirely:
assert.equal(qs.stringify({ a: null, b: undefined }), 'a=');
```
+The query string may optionally be prepended with a question mark:
+
+```javascript
+assert.equal(qs.stringify({ a: 'b', c: 'd' }, { addQueryPrefix: true }), '?a=b&c=d');
+```
+
The delimiter may be overridden with stringify as well:
```javascript
@@ -338,7 +357,7 @@ You may use the `sort` option to affect the order of parameter keys:
```javascript
function alphabeticalSort(a, b) {
- return a.localeCompare(b);
+ return a.localeCompare(b);
}
assert.equal(qs.stringify({ a: 'c', z: 'y', b : 'f' }, { sort: alphabeticalSort }), 'a=c&b=f&z=y');
```
@@ -349,17 +368,17 @@ pass an array, it will be used to select properties and array indices for string
```javascript
function filterFunc(prefix, value) {
- if (prefix == 'b') {
- // Return an `undefined` value to omit a property.
- return;
- }
- if (prefix == 'e[f]') {
- return value.getTime();
- }
- if (prefix == 'e[g][0]') {
- return value * 2;
- }
- return value;
+ if (prefix == 'b') {
+ // Return an `undefined` value to omit a property.
+ return;
+ }
+ if (prefix == 'e[f]') {
+ return value.getTime();
+ }
+ if (prefix == 'e[g][0]') {
+ return value * 2;
+ }
+ return value;
}
qs.stringify({ a: 'b', c: 'd', e: { f: new Date(123), g: [2] } }, { filter: filterFunc });
// 'a=b&c=d&e[f]=123&e[g][0]=4'
@@ -438,3 +457,19 @@ assert.equal(qs.stringify({ a: 'b c' }), 'a=b%20c');
assert.equal(qs.stringify({ a: 'b c' }, { format : 'RFC3986' }), 'a=b%20c');
assert.equal(qs.stringify({ a: 'b c' }, { format : 'RFC1738' }), 'a=b+c');
```
+
+[1]: https://npmjs.org/package/qs
+[2]: http://versionbadg.es/ljharb/qs.svg
+[3]: https://api.travis-ci.org/ljharb/qs.svg
+[4]: https://travis-ci.org/ljharb/qs
+[5]: https://david-dm.org/ljharb/qs.svg
+[6]: https://david-dm.org/ljharb/qs
+[7]: https://david-dm.org/ljharb/qs/dev-status.svg
+[8]: https://david-dm.org/ljharb/qs?type=dev
+[9]: https://ci.testling.com/ljharb/qs.png
+[10]: https://ci.testling.com/ljharb/qs
+[11]: https://nodei.co/npm/qs.png?downloads=true&stars=true
+[license-image]: http://img.shields.io/npm/l/qs.svg
+[license-url]: LICENSE
+[downloads-image]: http://img.shields.io/npm/dm/qs.svg
+[downloads-url]: http://npm-stat.com/charts.html?package=qs
diff --git a/deps/npm/node_modules/request/node_modules/qs/dist/qs.js b/deps/npm/node_modules/request/node_modules/qs/dist/qs.js
index 2d0d63ff26..713c6d1e86 100644
--- a/deps/npm/node_modules/request/node_modules/qs/dist/qs.js
+++ b/deps/npm/node_modules/request/node_modules/qs/dist/qs.js
@@ -52,19 +52,23 @@ var defaults = {
var parseValues = function parseQueryStringValues(str, options) {
var obj = {};
- var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);
+ var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
+ var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
+ var parts = cleanStr.split(options.delimiter, limit);
for (var i = 0; i < parts.length; ++i) {
var part = parts[i];
- var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;
+
+ var bracketEqualsPos = part.indexOf(']=');
+ var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
var key, val;
if (pos === -1) {
- key = options.decoder(part);
+ key = options.decoder(part, defaults.decoder);
val = options.strictNullHandling ? null : '';
} else {
- key = options.decoder(part.slice(0, pos));
- val = options.decoder(part.slice(pos + 1));
+ key = options.decoder(part.slice(0, pos), defaults.decoder);
+ val = options.decoder(part.slice(pos + 1), defaults.decoder);
}
if (has.call(obj, key)) {
obj[key] = [].concat(obj[key]).concat(val);
@@ -76,36 +80,38 @@ var parseValues = function parseQueryStringValues(str, options) {
return obj;
};
-var parseObject = function parseObjectRecursive(chain, val, options) {
- if (!chain.length) {
- return val;
- }
+var parseObject = function (chain, val, options) {
+ var leaf = val;
- var root = chain.shift();
+ for (var i = chain.length - 1; i >= 0; --i) {
+ var obj;
+ var root = chain[i];
- var obj;
- if (root === '[]') {
- obj = [];
- obj = obj.concat(parseObject(chain, val, options));
- } else {
- obj = options.plainObjects ? Object.create(null) : {};
- var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
- var index = parseInt(cleanRoot, 10);
- if (
- !isNaN(index) &&
- root !== cleanRoot &&
- String(index) === cleanRoot &&
- index >= 0 &&
- (options.parseArrays && index <= options.arrayLimit)
- ) {
+ if (root === '[]') {
obj = [];
- obj[index] = parseObject(chain, val, options);
+ obj = obj.concat(leaf);
} else {
- obj[cleanRoot] = parseObject(chain, val, options);
+ obj = options.plainObjects ? Object.create(null) : {};
+ var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
+ var index = parseInt(cleanRoot, 10);
+ if (
+ !isNaN(index)
+ && root !== cleanRoot
+ && String(index) === cleanRoot
+ && index >= 0
+ && (options.parseArrays && index <= options.arrayLimit)
+ ) {
+ obj = [];
+ obj[index] = leaf;
+ } else {
+ obj[cleanRoot] = leaf;
+ }
}
+
+ leaf = obj;
}
- return obj;
+ return leaf;
};
var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
@@ -164,12 +170,13 @@ var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
};
module.exports = function (str, opts) {
- var options = opts || {};
+ var options = opts ? utils.assign({}, opts) : {};
if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') {
throw new TypeError('Decoder has to be a function.');
}
+ options.ignoreQueryPrefix = options.ignoreQueryPrefix === true;
options.delimiter = typeof options.delimiter === 'string' || utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter;
options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth;
options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit;
@@ -253,7 +260,7 @@ var stringify = function stringify( // eslint-disable-line func-name-matching
obj = serializeDate(obj);
} else if (obj === null) {
if (strictNullHandling) {
- return encoder && !encodeValuesOnly ? encoder(prefix) : prefix;
+ return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder) : prefix;
}
obj = '';
@@ -261,8 +268,8 @@ var stringify = function stringify( // eslint-disable-line func-name-matching
if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || utils.isBuffer(obj)) {
if (encoder) {
- var keyValue = encodeValuesOnly ? prefix : encoder(prefix);
- return [formatter(keyValue) + '=' + formatter(encoder(obj))];
+ var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder);
+ return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder))];
}
return [formatter(prefix) + '=' + formatter(String(obj))];
}
@@ -326,7 +333,7 @@ var stringify = function stringify( // eslint-disable-line func-name-matching
module.exports = function (object, opts) {
var obj = object;
- var options = opts || {};
+ var options = opts ? utils.assign({}, opts) : {};
if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') {
throw new TypeError('Encoder has to be a function.');
@@ -342,7 +349,7 @@ module.exports = function (object, opts) {
var serializeDate = typeof options.serializeDate === 'function' ? options.serializeDate : defaults.serializeDate;
var encodeValuesOnly = typeof options.encodeValuesOnly === 'boolean' ? options.encodeValuesOnly : defaults.encodeValuesOnly;
if (typeof options.format === 'undefined') {
- options.format = formats.default;
+ options.format = formats['default'];
} else if (!Object.prototype.hasOwnProperty.call(formats.formatters, options.format)) {
throw new TypeError('Unknown format option provided.');
}
@@ -406,7 +413,10 @@ module.exports = function (object, opts) {
));
}
- return keys.join(delimiter);
+ var joined = keys.join(delimiter);
+ var prefix = options.addQueryPrefix === true ? '?' : '';
+
+ return joined.length > 0 ? prefix + joined : '';
};
},{"./formats":1,"./utils":5}],5:[function(require,module,exports){
@@ -423,7 +433,30 @@ var hexTable = (function () {
return array;
}());
-exports.arrayToObject = function (source, options) {
+var compactQueue = function compactQueue(queue) {
+ var obj;
+
+ while (queue.length) {
+ var item = queue.pop();
+ obj = item.obj[item.prop];
+
+ if (Array.isArray(obj)) {
+ var compacted = [];
+
+ for (var j = 0; j < obj.length; ++j) {
+ if (typeof obj[j] !== 'undefined') {
+ compacted.push(obj[j]);
+ }
+ }
+
+ item.obj[item.prop] = compacted;
+ }
+ }
+
+ return obj;
+};
+
+exports.arrayToObject = function arrayToObject(source, options) {
var obj = options && options.plainObjects ? Object.create(null) : {};
for (var i = 0; i < source.length; ++i) {
if (typeof source[i] !== 'undefined') {
@@ -434,7 +467,7 @@ exports.arrayToObject = function (source, options) {
return obj;
};
-exports.merge = function (target, source, options) {
+exports.merge = function merge(target, source, options) {
if (!source) {
return target;
}
@@ -480,7 +513,7 @@ exports.merge = function (target, source, options) {
return Object.keys(source).reduce(function (acc, key) {
var value = source[key];
- if (Object.prototype.hasOwnProperty.call(acc, key)) {
+ if (has.call(acc, key)) {
acc[key] = exports.merge(acc[key], value, options);
} else {
acc[key] = value;
@@ -489,6 +522,13 @@ exports.merge = function (target, source, options) {
}, mergeTarget);
};
+exports.assign = function assignSingleSource(target, source) {
+ return Object.keys(source).reduce(function (acc, key) {
+ acc[key] = source[key];
+ return acc;
+ }, target);
+};
+
exports.decode = function (str) {
try {
return decodeURIComponent(str.replace(/\+/g, ' '));
@@ -497,7 +537,7 @@ exports.decode = function (str) {
}
};
-exports.encode = function (str) {
+exports.encode = function encode(str) {
// This code was originally written by Brian White (mscdex) for the io.js core querystring library.
// It has been adapted here for stricter adherence to RFC 3986
if (str.length === 0) {
@@ -511,13 +551,13 @@ exports.encode = function (str) {
var c = string.charCodeAt(i);
if (
- c === 0x2D || // -
- c === 0x2E || // .
- c === 0x5F || // _
- c === 0x7E || // ~
- (c >= 0x30 && c <= 0x39) || // 0-9
- (c >= 0x41 && c <= 0x5A) || // a-z
- (c >= 0x61 && c <= 0x7A) // A-Z
+ c === 0x2D // -
+ || c === 0x2E // .
+ || c === 0x5F // _
+ || c === 0x7E // ~
+ || (c >= 0x30 && c <= 0x39) // 0-9
+ || (c >= 0x41 && c <= 0x5A) // a-z
+ || (c >= 0x61 && c <= 0x7A) // A-Z
) {
out += string.charAt(i);
continue;
@@ -540,52 +580,42 @@ exports.encode = function (str) {
i += 1;
c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
- out += hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]; // eslint-disable-line max-len
+ out += hexTable[0xF0 | (c >> 18)]
+ + hexTable[0x80 | ((c >> 12) & 0x3F)]
+ + hexTable[0x80 | ((c >> 6) & 0x3F)]
+ + hexTable[0x80 | (c & 0x3F)];
}
return out;
};
-exports.compact = function (obj, references) {
- if (typeof obj !== 'object' || obj === null) {
- return obj;
- }
-
- var refs = references || [];
- var lookup = refs.indexOf(obj);
- if (lookup !== -1) {
- return refs[lookup];
- }
-
- refs.push(obj);
+exports.compact = function compact(value) {
+ var queue = [{ obj: { o: value }, prop: 'o' }];
+ var refs = [];
- if (Array.isArray(obj)) {
- var compacted = [];
+ for (var i = 0; i < queue.length; ++i) {
+ var item = queue[i];
+ var obj = item.obj[item.prop];
- for (var i = 0; i < obj.length; ++i) {
- if (obj[i] && typeof obj[i] === 'object') {
- compacted.push(exports.compact(obj[i], refs));
- } else if (typeof obj[i] !== 'undefined') {
- compacted.push(obj[i]);
+ var keys = Object.keys(obj);
+ for (var j = 0; j < keys.length; ++j) {
+ var key = keys[j];
+ var val = obj[key];
+ if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
+ queue.push({ obj: obj, prop: key });
+ refs.push(val);
}
}
-
- return compacted;
}
- var keys = Object.keys(obj);
- keys.forEach(function (key) {
- obj[key] = exports.compact(obj[key], refs);
- });
-
- return obj;
+ return compactQueue(queue);
};
-exports.isRegExp = function (obj) {
+exports.isRegExp = function isRegExp(obj) {
return Object.prototype.toString.call(obj) === '[object RegExp]';
};
-exports.isBuffer = function (obj) {
+exports.isBuffer = function isBuffer(obj) {
if (obj === null || typeof obj === 'undefined') {
return false;
}
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 1307e9d797..8c9872ecc6 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
@@ -18,19 +18,23 @@ var defaults = {
var parseValues = function parseQueryStringValues(str, options) {
var obj = {};
- var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);
+ var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
+ var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
+ var parts = cleanStr.split(options.delimiter, limit);
for (var i = 0; i < parts.length; ++i) {
var part = parts[i];
- var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;
+
+ var bracketEqualsPos = part.indexOf(']=');
+ var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
var key, val;
if (pos === -1) {
- key = options.decoder(part);
+ key = options.decoder(part, defaults.decoder);
val = options.strictNullHandling ? null : '';
} else {
- key = options.decoder(part.slice(0, pos));
- val = options.decoder(part.slice(pos + 1));
+ key = options.decoder(part.slice(0, pos), defaults.decoder);
+ val = options.decoder(part.slice(pos + 1), defaults.decoder);
}
if (has.call(obj, key)) {
obj[key] = [].concat(obj[key]).concat(val);
@@ -42,36 +46,38 @@ var parseValues = function parseQueryStringValues(str, options) {
return obj;
};
-var parseObject = function parseObjectRecursive(chain, val, options) {
- if (!chain.length) {
- return val;
- }
+var parseObject = function (chain, val, options) {
+ var leaf = val;
+
+ for (var i = chain.length - 1; i >= 0; --i) {
+ var obj;
+ var root = chain[i];
- var root = chain.shift();
-
- var obj;
- if (root === '[]') {
- obj = [];
- obj = obj.concat(parseObject(chain, val, options));
- } else {
- obj = options.plainObjects ? Object.create(null) : {};
- var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
- var index = parseInt(cleanRoot, 10);
- if (
- !isNaN(index) &&
- root !== cleanRoot &&
- String(index) === cleanRoot &&
- index >= 0 &&
- (options.parseArrays && index <= options.arrayLimit)
- ) {
+ if (root === '[]') {
obj = [];
- obj[index] = parseObject(chain, val, options);
+ obj = obj.concat(leaf);
} else {
- obj[cleanRoot] = parseObject(chain, val, options);
+ obj = options.plainObjects ? Object.create(null) : {};
+ var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
+ var index = parseInt(cleanRoot, 10);
+ if (
+ !isNaN(index)
+ && root !== cleanRoot
+ && String(index) === cleanRoot
+ && index >= 0
+ && (options.parseArrays && index <= options.arrayLimit)
+ ) {
+ obj = [];
+ obj[index] = leaf;
+ } else {
+ obj[cleanRoot] = leaf;
+ }
}
+
+ leaf = obj;
}
- return obj;
+ return leaf;
};
var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
@@ -130,12 +136,13 @@ var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
};
module.exports = function (str, opts) {
- var options = opts || {};
+ var options = opts ? utils.assign({}, opts) : {};
if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') {
throw new TypeError('Decoder has to be a function.');
}
+ options.ignoreQueryPrefix = options.ignoreQueryPrefix === true;
options.delimiter = typeof options.delimiter === 'string' || utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter;
options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth;
options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit;
diff --git a/deps/npm/node_modules/request/node_modules/qs/lib/stringify.js b/deps/npm/node_modules/request/node_modules/qs/lib/stringify.js
index 7694988c09..ab915ac463 100644
--- a/deps/npm/node_modules/request/node_modules/qs/lib/stringify.js
+++ b/deps/npm/node_modules/request/node_modules/qs/lib/stringify.js
@@ -50,7 +50,7 @@ var stringify = function stringify( // eslint-disable-line func-name-matching
obj = serializeDate(obj);
} else if (obj === null) {
if (strictNullHandling) {
- return encoder && !encodeValuesOnly ? encoder(prefix) : prefix;
+ return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder) : prefix;
}
obj = '';
@@ -58,8 +58,8 @@ var stringify = function stringify( // eslint-disable-line func-name-matching
if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || utils.isBuffer(obj)) {
if (encoder) {
- var keyValue = encodeValuesOnly ? prefix : encoder(prefix);
- return [formatter(keyValue) + '=' + formatter(encoder(obj))];
+ var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder);
+ return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder))];
}
return [formatter(prefix) + '=' + formatter(String(obj))];
}
@@ -123,7 +123,7 @@ var stringify = function stringify( // eslint-disable-line func-name-matching
module.exports = function (object, opts) {
var obj = object;
- var options = opts || {};
+ var options = opts ? utils.assign({}, opts) : {};
if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') {
throw new TypeError('Encoder has to be a function.');
@@ -139,7 +139,7 @@ module.exports = function (object, opts) {
var serializeDate = typeof options.serializeDate === 'function' ? options.serializeDate : defaults.serializeDate;
var encodeValuesOnly = typeof options.encodeValuesOnly === 'boolean' ? options.encodeValuesOnly : defaults.encodeValuesOnly;
if (typeof options.format === 'undefined') {
- options.format = formats.default;
+ options.format = formats['default'];
} else if (!Object.prototype.hasOwnProperty.call(formats.formatters, options.format)) {
throw new TypeError('Unknown format option provided.');
}
@@ -203,5 +203,8 @@ module.exports = function (object, opts) {
));
}
- return keys.join(delimiter);
+ var joined = keys.join(delimiter);
+ var prefix = options.addQueryPrefix === true ? '?' : '';
+
+ return joined.length > 0 ? prefix + joined : '';
};
diff --git a/deps/npm/node_modules/request/node_modules/qs/lib/utils.js b/deps/npm/node_modules/request/node_modules/qs/lib/utils.js
index b214332376..06cae2f09a 100644
--- a/deps/npm/node_modules/request/node_modules/qs/lib/utils.js
+++ b/deps/npm/node_modules/request/node_modules/qs/lib/utils.js
@@ -11,7 +11,30 @@ var hexTable = (function () {
return array;
}());
-exports.arrayToObject = function (source, options) {
+var compactQueue = function compactQueue(queue) {
+ var obj;
+
+ while (queue.length) {
+ var item = queue.pop();
+ obj = item.obj[item.prop];
+
+ if (Array.isArray(obj)) {
+ var compacted = [];
+
+ for (var j = 0; j < obj.length; ++j) {
+ if (typeof obj[j] !== 'undefined') {
+ compacted.push(obj[j]);
+ }
+ }
+
+ item.obj[item.prop] = compacted;
+ }
+ }
+
+ return obj;
+};
+
+exports.arrayToObject = function arrayToObject(source, options) {
var obj = options && options.plainObjects ? Object.create(null) : {};
for (var i = 0; i < source.length; ++i) {
if (typeof source[i] !== 'undefined') {
@@ -22,7 +45,7 @@ exports.arrayToObject = function (source, options) {
return obj;
};
-exports.merge = function (target, source, options) {
+exports.merge = function merge(target, source, options) {
if (!source) {
return target;
}
@@ -68,7 +91,7 @@ exports.merge = function (target, source, options) {
return Object.keys(source).reduce(function (acc, key) {
var value = source[key];
- if (Object.prototype.hasOwnProperty.call(acc, key)) {
+ if (has.call(acc, key)) {
acc[key] = exports.merge(acc[key], value, options);
} else {
acc[key] = value;
@@ -77,6 +100,13 @@ exports.merge = function (target, source, options) {
}, mergeTarget);
};
+exports.assign = function assignSingleSource(target, source) {
+ return Object.keys(source).reduce(function (acc, key) {
+ acc[key] = source[key];
+ return acc;
+ }, target);
+};
+
exports.decode = function (str) {
try {
return decodeURIComponent(str.replace(/\+/g, ' '));
@@ -85,7 +115,7 @@ exports.decode = function (str) {
}
};
-exports.encode = function (str) {
+exports.encode = function encode(str) {
// This code was originally written by Brian White (mscdex) for the io.js core querystring library.
// It has been adapted here for stricter adherence to RFC 3986
if (str.length === 0) {
@@ -99,13 +129,13 @@ exports.encode = function (str) {
var c = string.charCodeAt(i);
if (
- c === 0x2D || // -
- c === 0x2E || // .
- c === 0x5F || // _
- c === 0x7E || // ~
- (c >= 0x30 && c <= 0x39) || // 0-9
- (c >= 0x41 && c <= 0x5A) || // a-z
- (c >= 0x61 && c <= 0x7A) // A-Z
+ c === 0x2D // -
+ || c === 0x2E // .
+ || c === 0x5F // _
+ || c === 0x7E // ~
+ || (c >= 0x30 && c <= 0x39) // 0-9
+ || (c >= 0x41 && c <= 0x5A) // a-z
+ || (c >= 0x61 && c <= 0x7A) // A-Z
) {
out += string.charAt(i);
continue;
@@ -128,52 +158,42 @@ exports.encode = function (str) {
i += 1;
c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
- out += hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]; // eslint-disable-line max-len
+ out += hexTable[0xF0 | (c >> 18)]
+ + hexTable[0x80 | ((c >> 12) & 0x3F)]
+ + hexTable[0x80 | ((c >> 6) & 0x3F)]
+ + hexTable[0x80 | (c & 0x3F)];
}
return out;
};
-exports.compact = function (obj, references) {
- if (typeof obj !== 'object' || obj === null) {
- return obj;
- }
-
- var refs = references || [];
- var lookup = refs.indexOf(obj);
- if (lookup !== -1) {
- return refs[lookup];
- }
-
- refs.push(obj);
-
- if (Array.isArray(obj)) {
- var compacted = [];
-
- for (var i = 0; i < obj.length; ++i) {
- if (obj[i] && typeof obj[i] === 'object') {
- compacted.push(exports.compact(obj[i], refs));
- } else if (typeof obj[i] !== 'undefined') {
- compacted.push(obj[i]);
+exports.compact = function compact(value) {
+ var queue = [{ obj: { o: value }, prop: 'o' }];
+ var refs = [];
+
+ for (var i = 0; i < queue.length; ++i) {
+ var item = queue[i];
+ var obj = item.obj[item.prop];
+
+ var keys = Object.keys(obj);
+ for (var j = 0; j < keys.length; ++j) {
+ var key = keys[j];
+ var val = obj[key];
+ if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
+ queue.push({ obj: obj, prop: key });
+ refs.push(val);
}
}
-
- return compacted;
}
- var keys = Object.keys(obj);
- keys.forEach(function (key) {
- obj[key] = exports.compact(obj[key], refs);
- });
-
- return obj;
+ return compactQueue(queue);
};
-exports.isRegExp = function (obj) {
+exports.isRegExp = function isRegExp(obj) {
return Object.prototype.toString.call(obj) === '[object RegExp]';
};
-exports.isBuffer = function (obj) {
+exports.isBuffer = function isBuffer(obj) {
if (obj === null || typeof obj === 'undefined') {
return false;
}
diff --git a/deps/npm/node_modules/request/node_modules/qs/package.json b/deps/npm/node_modules/request/node_modules/qs/package.json
index 84e2c9c304..a2ba1e368b 100644
--- a/deps/npm/node_modules/request/node_modules/qs/package.json
+++ b/deps/npm/node_modules/request/node_modules/qs/package.json
@@ -1,28 +1,27 @@
{
- "_from": "qs@~6.4.0",
- "_id": "qs@6.4.0",
- "_integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=",
+ "_from": "qs@~6.5.1",
+ "_id": "qs@6.5.1",
+ "_inBundle": false,
+ "_integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==",
"_location": "/request/qs",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
- "raw": "qs@~6.4.0",
+ "raw": "qs@~6.5.1",
"name": "qs",
"escapedName": "qs",
- "rawSpec": "~6.4.0",
+ "rawSpec": "~6.5.1",
"saveSpec": null,
- "fetchSpec": "~6.4.0"
+ "fetchSpec": "~6.5.1"
},
"_requiredBy": [
"/request"
],
- "_resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz",
- "_shasum": "13e26d28ad6b0ffaa91312cd3bf708ed351e7233",
- "_shrinkwrap": null,
- "_spec": "qs@~6.4.0",
- "_where": "/Users/zkat/Documents/code/npm/node_modules/request",
- "bin": null,
+ "_resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz",
+ "_shasum": "349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8",
+ "_spec": "qs@~6.5.1",
+ "_where": "/Users/rebecca/code/npm/node_modules/request",
"bugs": {
"url": "https://github.com/ljharb/qs/issues"
},
@@ -38,17 +37,17 @@
"deprecated": false,
"description": "A querystring parser that supports nesting and arrays, with a depth limit",
"devDependencies": {
- "@ljharb/eslint-config": "^11.0.0",
- "browserify": "^14.1.0",
+ "@ljharb/eslint-config": "^12.2.1",
+ "browserify": "^14.4.0",
"covert": "^1.1.0",
- "eslint": "^3.17.0",
+ "editorconfig-tools": "^0.1.1",
+ "eslint": "^4.6.1",
"evalmd": "^0.0.17",
- "iconv-lite": "^0.4.15",
+ "iconv-lite": "^0.4.18",
"mkdirp": "^0.5.1",
- "parallelshell": "^2.0.0",
"qs-iconv": "^1.0.4",
"safe-publish-latest": "^1.1.1",
- "tape": "^4.6.3"
+ "tape": "^4.8.0"
},
"engines": {
"node": ">=0.6"
@@ -61,8 +60,6 @@
"license": "BSD-3-Clause",
"main": "lib/index.js",
"name": "qs",
- "optionalDependencies": {},
- "peerDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/ljharb/qs.git"
@@ -71,11 +68,12 @@
"coverage": "covert test",
"dist": "mkdirp dist && browserify --standalone Qs lib/index.js > dist/qs.js",
"lint": "eslint lib/*.js test/*.js",
+ "prelint": "editorconfig-tools check * lib/* test/*",
"prepublish": "safe-publish-latest && npm run dist",
"pretest": "npm run --silent readme && npm run --silent lint",
"readme": "evalmd README.md",
"test": "npm run --silent coverage",
"tests-only": "node test"
},
- "version": "6.4.0"
+ "version": "6.5.1"
}
diff --git a/deps/npm/node_modules/request/node_modules/qs/test/parse.js b/deps/npm/node_modules/request/node_modules/qs/test/parse.js
index e451e91fe3..d7d8641926 100644
--- a/deps/npm/node_modules/request/node_modules/qs/test/parse.js
+++ b/deps/npm/node_modules/request/node_modules/qs/test/parse.js
@@ -2,6 +2,7 @@
var test = require('tape');
var qs = require('../');
+var utils = require('../lib/utils');
var iconv = require('iconv-lite');
test('parse()', function (t) {
@@ -304,6 +305,13 @@ test('parse()', function (t) {
st.end();
});
+ t.test('allows for query string prefix', function (st) {
+ st.deepEqual(qs.parse('?foo=bar', { ignoreQueryPrefix: true }), { foo: 'bar' });
+ st.deepEqual(qs.parse('foo=bar', { ignoreQueryPrefix: true }), { foo: 'bar' });
+ st.deepEqual(qs.parse('?foo=bar', { ignoreQueryPrefix: false }), { '?foo': 'bar' });
+ st.end();
+ });
+
t.test('parses an object', function (st) {
var input = {
'user[name]': { 'pop[bob]': 3 },
@@ -388,6 +396,33 @@ test('parse()', function (t) {
st.end();
});
+ t.test('does not crash when parsing deep objects', function (st) {
+ var parsed;
+ var str = 'foo';
+
+ for (var i = 0; i < 5000; i++) {
+ str += '[p]';
+ }
+
+ str += '=bar';
+
+ st.doesNotThrow(function () {
+ parsed = qs.parse(str, { depth: 5000 });
+ });
+
+ st.equal('foo' in parsed, true, 'parsed has "foo" property');
+
+ var depth = 0;
+ var ref = parsed.foo;
+ while ((ref = ref.p)) {
+ depth += 1;
+ }
+
+ st.equal(depth, 5000, 'parsed is 5000 properties deep');
+
+ st.end();
+ });
+
t.test('parses null objects correctly', { skip: !Object.create }, function (st) {
var a = Object.create(null);
a.b = 'c';
@@ -510,10 +545,29 @@ test('parse()', function (t) {
st.end();
});
+ t.test('receives the default decoder as a second argument', function (st) {
+ st.plan(1);
+ qs.parse('a', {
+ decoder: function (str, defaultDecoder) {
+ st.equal(defaultDecoder, utils.decode);
+ }
+ });
+ st.end();
+ });
+
t.test('throws error with wrong decoder', function (st) {
- st.throws(function () {
+ st['throws'](function () {
qs.parse({}, { decoder: 'string' });
}, new TypeError('Decoder has to be a function.'));
st.end();
});
+
+ t.test('does not mutate the options argument', function (st) {
+ var options = {};
+ qs.parse('a[b]=true', options);
+ st.deepEqual(options, {});
+ st.end();
+ });
+
+ t.end();
});
diff --git a/deps/npm/node_modules/request/node_modules/qs/test/stringify.js b/deps/npm/node_modules/request/node_modules/qs/test/stringify.js
index 711dae507d..124a99dca4 100644
--- a/deps/npm/node_modules/request/node_modules/qs/test/stringify.js
+++ b/deps/npm/node_modules/request/node_modules/qs/test/stringify.js
@@ -2,6 +2,7 @@
var test = require('tape');
var qs = require('../');
+var utils = require('../lib/utils');
var iconv = require('iconv-lite');
test('stringify()', function (t) {
@@ -17,6 +18,16 @@ test('stringify()', function (t) {
st.end();
});
+ t.test('adds query prefix', function (st) {
+ st.equal(qs.stringify({ a: 'b' }, { addQueryPrefix: true }), '?a=b');
+ st.end();
+ });
+
+ t.test('with query prefix, outputs blank string given an empty object', function (st) {
+ st.equal(qs.stringify({}, { addQueryPrefix: true }), '');
+ st.end();
+ });
+
t.test('stringifies a nested object', function (st) {
st.equal(qs.stringify({ a: { b: 'c' } }), 'a%5Bb%5D=c');
st.equal(qs.stringify({ a: { b: { c: { d: 'e' } } } }), 'a%5Bb%5D%5Bc%5D%5Bd%5D=e');
@@ -452,8 +463,18 @@ test('stringify()', function (t) {
st.end();
});
+ t.test('receives the default encoder as a second argument', function (st) {
+ st.plan(2);
+ qs.stringify({ a: 1 }, {
+ encoder: function (str, defaultEncoder) {
+ st.equal(defaultEncoder, utils.encode);
+ }
+ });
+ st.end();
+ });
+
t.test('throws error with wrong encoder', function (st) {
- st.throws(function () {
+ st['throws'](function () {
qs.stringify({}, { encoder: 'string' });
}, new TypeError('Encoder has to be a function.'));
st.end();
@@ -483,7 +504,7 @@ test('stringify()', function (t) {
mutatedDate.toISOString = function () {
throw new SyntaxError();
};
- st.throws(function () {
+ st['throws'](function () {
mutatedDate.toISOString();
}, SyntaxError);
st.equal(
@@ -525,7 +546,7 @@ test('stringify()', function (t) {
t.test('Edge cases and unknown formats', function (st) {
['UFO1234', false, 1234, null, {}, []].forEach(
function (format) {
- st.throws(
+ st['throws'](
function () {
qs.stringify({ a: 'b c' }, { format: format });
},
@@ -564,4 +585,12 @@ test('stringify()', function (t) {
st.end();
});
+ t.test('does not mutate the options argument', function (st) {
+ var options = {};
+ qs.stringify({}, options);
+ st.deepEqual(options, {});
+ st.end();
+ });
+
+ t.end();
});
diff --git a/deps/npm/node_modules/request/node_modules/qs/test/utils.js b/deps/npm/node_modules/request/node_modules/qs/test/utils.js
index 0721dd8ec6..eff4011a40 100644
--- a/deps/npm/node_modules/request/node_modules/qs/test/utils.js
+++ b/deps/npm/node_modules/request/node_modules/qs/test/utils.js
@@ -20,3 +20,15 @@ test('merge()', function (t) {
t.end();
});
+
+test('assign()', function (t) {
+ var target = { a: 1, b: 2 };
+ var source = { b: 3, c: 4 };
+ var result = utils.assign(target, source);
+
+ t.equal(result, target, 'returns the target');
+ t.deepEqual(target, { a: 1, b: 3, c: 4 }, 'target and source are merged');
+ t.deepEqual(source, { b: 3, c: 4 }, 'source is untouched');
+
+ t.end();
+});