diff options
author | Kat Marchán <kzm@zkat.tech> | 2018-07-11 00:54:34 +0300 |
---|---|---|
committer | Kat Marchán <kzm@zkat.tech> | 2018-07-11 00:54:34 +0300 |
commit | d9b2712a670e5e78334e83f89a5ed49616f1f3d3 (patch) | |
tree | df79890df558bd30e485eba1d8a2e2282e17a859 /node_modules/qs | |
parent | 843bdd6b1ac2c68cfbc78a75b62f3a7124a710ea (diff) |
request@2.81.0
Downgraded to allow better deduplication
Diffstat (limited to 'node_modules/qs')
-rw-r--r-- | node_modules/qs/.editorconfig | 30 | ||||
-rw-r--r-- | node_modules/qs/.jscs.json | 176 | ||||
-rw-r--r-- | node_modules/qs/CHANGELOG.md | 51 | ||||
-rw-r--r-- | node_modules/qs/README.md | 117 | ||||
-rw-r--r-- | node_modules/qs/dist/qs.js | 205 | ||||
-rw-r--r-- | node_modules/qs/lib/parse.js | 67 | ||||
-rw-r--r-- | node_modules/qs/lib/stringify.js | 15 | ||||
-rw-r--r-- | node_modules/qs/lib/utils.js | 125 | ||||
-rw-r--r-- | node_modules/qs/package.json | 36 | ||||
-rw-r--r-- | node_modules/qs/test/parse.js | 61 | ||||
-rw-r--r-- | node_modules/qs/test/stringify.js | 42 | ||||
-rw-r--r-- | node_modules/qs/test/utils.js | 12 |
12 files changed, 408 insertions, 529 deletions
diff --git a/node_modules/qs/.editorconfig b/node_modules/qs/.editorconfig deleted file mode 100644 index b2654e7ac..000000000 --- a/node_modules/qs/.editorconfig +++ /dev/null @@ -1,30 +0,0 @@ -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/node_modules/qs/.jscs.json b/node_modules/qs/.jscs.json new file mode 100644 index 000000000..3d099c4b1 --- /dev/null +++ b/node_modules/qs/.jscs.json @@ -0,0 +1,176 @@ +{ + "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/node_modules/qs/CHANGELOG.md b/node_modules/qs/CHANGELOG.md index fe5232091..85e69b0a2 100644 --- a/node_modules/qs/CHANGELOG.md +++ b/node_modules/qs/CHANGELOG.md @@ -1,29 +1,3 @@ -## **6.5.2** -- [Fix] use `safer-buffer` instead of `Buffer` constructor -- [Refactor] utils: `module.exports` one thing, instead of mutating `exports` (#230) -- [Dev Deps] update `browserify`, `eslint`, `iconv-lite`, `safer-buffer`, `tape`, `browserify` - -## **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) @@ -33,13 +7,6 @@ - [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` @@ -66,12 +33,6 @@ - [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 @@ -87,12 +48,6 @@ - [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 @@ -101,12 +56,6 @@ - [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/node_modules/qs/README.md b/node_modules/qs/README.md index d81196662..32fc3123f 100644 --- a/node_modules/qs/README.md +++ b/node_modules/qs/README.md @@ -1,15 +1,9 @@ -# qs <sup>[![Version Badge][2]][1]</sup> - -[![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] +# qs A querystring parsing and stringifying library with some added security. +[![Build Status](https://api.travis-ci.org/ljharb/qs.svg)](http://travis-ci.org/ljharb/qs) + Lead Maintainer: [Jordan Harband](https://github.com/ljharb) The **qs** module was originally created and maintained by [TJ Holowaychuk](https://github.com/visionmedia/node-querystring). @@ -39,9 +33,9 @@ For example, the string `'foo[bar]=baz'` converts to: ```javascript assert.deepEqual(qs.parse('foo[bar]=baz'), { - foo: { - bar: 'baz' - } + foo: { + bar: 'baz' + } }); ``` @@ -63,7 +57,7 @@ URI encoded strings work too: ```javascript assert.deepEqual(qs.parse('a%5Bb%5D=c'), { - a: { b: 'c' } + a: { b: 'c' } }); ``` @@ -71,11 +65,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' } + } }); ``` @@ -84,19 +78,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); @@ -118,13 +112,6 @@ 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 @@ -240,10 +227,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'); ``` @@ -251,8 +238,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 }}) ``` @@ -262,8 +249,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 }}) ``` @@ -330,12 +317,6 @@ 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 @@ -357,7 +338,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'); ``` @@ -368,17 +349,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' @@ -457,19 +438,3 @@ 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/node_modules/qs/dist/qs.js b/node_modules/qs/dist/qs.js index ecf7ba44c..2d0d63ff2 100644 --- a/node_modules/qs/dist/qs.js +++ b/node_modules/qs/dist/qs.js @@ -1,4 +1,4 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Qs = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Qs = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ 'use strict'; var replace = String.prototype.replace; @@ -52,23 +52,19 @@ var defaults = { var parseValues = function parseQueryStringValues(str, options) { var obj = {}; - var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str; - var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit; - var parts = cleanStr.split(options.delimiter, limit); + var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit); for (var i = 0; i < parts.length; ++i) { var part = parts[i]; - - var bracketEqualsPos = part.indexOf(']='); - var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1; + var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1; var key, val; if (pos === -1) { - key = options.decoder(part, defaults.decoder); + key = options.decoder(part); val = options.strictNullHandling ? null : ''; } else { - key = options.decoder(part.slice(0, pos), defaults.decoder); - val = options.decoder(part.slice(pos + 1), defaults.decoder); + key = options.decoder(part.slice(0, pos)); + val = options.decoder(part.slice(pos + 1)); } if (has.call(obj, key)) { obj[key] = [].concat(obj[key]).concat(val); @@ -80,38 +76,36 @@ var parseValues = function parseQueryStringValues(str, options) { return obj; }; -var parseObject = function (chain, val, options) { - var leaf = val; +var parseObject = function parseObjectRecursive(chain, val, options) { + if (!chain.length) { + return val; + } - for (var i = chain.length - 1; i >= 0; --i) { - var obj; - var root = chain[i]; + var root = chain.shift(); - if (root === '[]') { + 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) + ) { obj = []; - obj = obj.concat(leaf); + obj[index] = 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) - ) { - obj = []; - obj[index] = leaf; - } else { - obj[cleanRoot] = leaf; - } + obj[cleanRoot] = parseObject(chain, val, options); } - - leaf = obj; } - return leaf; + return obj; }; var parseKeys = function parseQueryStringKeys(givenKey, val, options) { @@ -170,13 +164,12 @@ var parseKeys = function parseQueryStringKeys(givenKey, val, options) { }; module.exports = function (str, opts) { - var options = opts ? utils.assign({}, opts) : {}; + var options = 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; @@ -260,7 +253,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, defaults.encoder) : prefix; + return encoder && !encodeValuesOnly ? encoder(prefix) : prefix; } obj = ''; @@ -268,8 +261,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, defaults.encoder); - return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder))]; + var keyValue = encodeValuesOnly ? prefix : encoder(prefix); + return [formatter(keyValue) + '=' + formatter(encoder(obj))]; } return [formatter(prefix) + '=' + formatter(String(obj))]; } @@ -333,7 +326,7 @@ var stringify = function stringify( // eslint-disable-line func-name-matching module.exports = function (object, opts) { var obj = object; - var options = opts ? utils.assign({}, opts) : {}; + var options = opts || {}; if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') { throw new TypeError('Encoder has to be a function.'); @@ -349,7 +342,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.'); } @@ -413,10 +406,7 @@ module.exports = function (object, opts) { )); } - var joined = keys.join(delimiter); - var prefix = options.addQueryPrefix === true ? '?' : ''; - - return joined.length > 0 ? prefix + joined : ''; + return keys.join(delimiter); }; },{"./formats":1,"./utils":5}],5:[function(require,module,exports){ @@ -433,30 +423,7 @@ var hexTable = (function () { return array; }()); -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; -}; - -var arrayToObject = function arrayToObject(source, options) { +exports.arrayToObject = function (source, options) { var obj = options && options.plainObjects ? Object.create(null) : {}; for (var i = 0; i < source.length; ++i) { if (typeof source[i] !== 'undefined') { @@ -467,7 +434,7 @@ var arrayToObject = function arrayToObject(source, options) { return obj; }; -var merge = function merge(target, source, options) { +exports.merge = function (target, source, options) { if (!source) { return target; } @@ -492,14 +459,14 @@ var merge = function merge(target, source, options) { var mergeTarget = target; if (Array.isArray(target) && !Array.isArray(source)) { - mergeTarget = arrayToObject(target, options); + mergeTarget = exports.arrayToObject(target, options); } if (Array.isArray(target) && Array.isArray(source)) { source.forEach(function (item, i) { if (has.call(target, i)) { if (target[i] && typeof target[i] === 'object') { - target[i] = merge(target[i], item, options); + target[i] = exports.merge(target[i], item, options); } else { target.push(item); } @@ -513,8 +480,8 @@ var merge = function merge(target, source, options) { return Object.keys(source).reduce(function (acc, key) { var value = source[key]; - if (has.call(acc, key)) { - acc[key] = merge(acc[key], value, options); + if (Object.prototype.hasOwnProperty.call(acc, key)) { + acc[key] = exports.merge(acc[key], value, options); } else { acc[key] = value; } @@ -522,14 +489,7 @@ var merge = function merge(target, source, options) { }, mergeTarget); }; -var assign = function assignSingleSource(target, source) { - return Object.keys(source).reduce(function (acc, key) { - acc[key] = source[key]; - return acc; - }, target); -}; - -var decode = function (str) { +exports.decode = function (str) { try { return decodeURIComponent(str.replace(/\+/g, ' ')); } catch (e) { @@ -537,7 +497,7 @@ var decode = function (str) { } }; -var encode = function encode(str) { +exports.encode = function (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) { @@ -551,13 +511,13 @@ var encode = function encode(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; @@ -580,42 +540,52 @@ var encode = function encode(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)]; + out += hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]; // eslint-disable-line max-len } return out; }; -var compact = function compact(value) { - var queue = [{ obj: { o: value }, prop: 'o' }]; - var refs = []; +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]; + } - for (var i = 0; i < queue.length; ++i) { - var item = queue[i]; - var obj = item.obj[item.prop]; + refs.push(obj); - 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); + 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]); } } + + return compacted; } - return compactQueue(queue); + var keys = Object.keys(obj); + keys.forEach(function (key) { + obj[key] = exports.compact(obj[key], refs); + }); + + return obj; }; -var isRegExp = function isRegExp(obj) { +exports.isRegExp = function (obj) { return Object.prototype.toString.call(obj) === '[object RegExp]'; }; -var isBuffer = function isBuffer(obj) { +exports.isBuffer = function (obj) { if (obj === null || typeof obj === 'undefined') { return false; } @@ -623,16 +593,5 @@ var isBuffer = function isBuffer(obj) { return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj)); }; -module.exports = { - arrayToObject: arrayToObject, - assign: assign, - compact: compact, - decode: decode, - encode: encode, - isBuffer: isBuffer, - isRegExp: isRegExp, - merge: merge -}; - },{}]},{},[2])(2) -}); +});
\ No newline at end of file diff --git a/node_modules/qs/lib/parse.js b/node_modules/qs/lib/parse.js index 8c9872ecc..1307e9d79 100644 --- a/node_modules/qs/lib/parse.js +++ b/node_modules/qs/lib/parse.js @@ -18,23 +18,19 @@ var defaults = { var parseValues = function parseQueryStringValues(str, options) { var obj = {}; - var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str; - var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit; - var parts = cleanStr.split(options.delimiter, limit); + var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit); for (var i = 0; i < parts.length; ++i) { var part = parts[i]; - - var bracketEqualsPos = part.indexOf(']='); - var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1; + var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1; var key, val; if (pos === -1) { - key = options.decoder(part, defaults.decoder); + key = options.decoder(part); val = options.strictNullHandling ? null : ''; } else { - key = options.decoder(part.slice(0, pos), defaults.decoder); - val = options.decoder(part.slice(pos + 1), defaults.decoder); + key = options.decoder(part.slice(0, pos)); + val = options.decoder(part.slice(pos + 1)); } if (has.call(obj, key)) { obj[key] = [].concat(obj[key]).concat(val); @@ -46,38 +42,36 @@ var parseValues = function parseQueryStringValues(str, options) { return obj; }; -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 parseObject = function parseObjectRecursive(chain, val, options) { + if (!chain.length) { + return val; + } - if (root === '[]') { + 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) + ) { obj = []; - obj = obj.concat(leaf); + obj[index] = 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) - ) { - obj = []; - obj[index] = leaf; - } else { - obj[cleanRoot] = leaf; - } + obj[cleanRoot] = parseObject(chain, val, options); } - - leaf = obj; } - return leaf; + return obj; }; var parseKeys = function parseQueryStringKeys(givenKey, val, options) { @@ -136,13 +130,12 @@ var parseKeys = function parseQueryStringKeys(givenKey, val, options) { }; module.exports = function (str, opts) { - var options = opts ? utils.assign({}, opts) : {}; + var options = 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/node_modules/qs/lib/stringify.js b/node_modules/qs/lib/stringify.js index ab915ac46..7694988c0 100644 --- a/node_modules/qs/lib/stringify.js +++ b/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, defaults.encoder) : prefix; + return encoder && !encodeValuesOnly ? encoder(prefix) : 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, defaults.encoder); - return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder))]; + var keyValue = encodeValuesOnly ? prefix : encoder(prefix); + return [formatter(keyValue) + '=' + formatter(encoder(obj))]; } 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 ? utils.assign({}, opts) : {}; + var options = 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,8 +203,5 @@ module.exports = function (object, opts) { )); } - var joined = keys.join(delimiter); - var prefix = options.addQueryPrefix === true ? '?' : ''; - - return joined.length > 0 ? prefix + joined : ''; + return keys.join(delimiter); }; diff --git a/node_modules/qs/lib/utils.js b/node_modules/qs/lib/utils.js index 8775a3270..b21433237 100644 --- a/node_modules/qs/lib/utils.js +++ b/node_modules/qs/lib/utils.js @@ -11,30 +11,7 @@ var hexTable = (function () { return array; }()); -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; -}; - -var arrayToObject = function arrayToObject(source, options) { +exports.arrayToObject = function (source, options) { var obj = options && options.plainObjects ? Object.create(null) : {}; for (var i = 0; i < source.length; ++i) { if (typeof source[i] !== 'undefined') { @@ -45,7 +22,7 @@ var arrayToObject = function arrayToObject(source, options) { return obj; }; -var merge = function merge(target, source, options) { +exports.merge = function (target, source, options) { if (!source) { return target; } @@ -70,14 +47,14 @@ var merge = function merge(target, source, options) { var mergeTarget = target; if (Array.isArray(target) && !Array.isArray(source)) { - mergeTarget = arrayToObject(target, options); + mergeTarget = exports.arrayToObject(target, options); } if (Array.isArray(target) && Array.isArray(source)) { source.forEach(function (item, i) { if (has.call(target, i)) { if (target[i] && typeof target[i] === 'object') { - target[i] = merge(target[i], item, options); + target[i] = exports.merge(target[i], item, options); } else { target.push(item); } @@ -91,8 +68,8 @@ var merge = function merge(target, source, options) { return Object.keys(source).reduce(function (acc, key) { var value = source[key]; - if (has.call(acc, key)) { - acc[key] = merge(acc[key], value, options); + if (Object.prototype.hasOwnProperty.call(acc, key)) { + acc[key] = exports.merge(acc[key], value, options); } else { acc[key] = value; } @@ -100,14 +77,7 @@ var merge = function merge(target, source, options) { }, mergeTarget); }; -var assign = function assignSingleSource(target, source) { - return Object.keys(source).reduce(function (acc, key) { - acc[key] = source[key]; - return acc; - }, target); -}; - -var decode = function (str) { +exports.decode = function (str) { try { return decodeURIComponent(str.replace(/\+/g, ' ')); } catch (e) { @@ -115,7 +85,7 @@ var decode = function (str) { } }; -var encode = function encode(str) { +exports.encode = function (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) { @@ -129,13 +99,13 @@ var encode = function encode(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; @@ -158,56 +128,55 @@ var encode = function encode(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)]; + out += hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]; // eslint-disable-line max-len } return out; }; -var 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); +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]); } } + + return compacted; } - return compactQueue(queue); + var keys = Object.keys(obj); + keys.forEach(function (key) { + obj[key] = exports.compact(obj[key], refs); + }); + + return obj; }; -var isRegExp = function isRegExp(obj) { +exports.isRegExp = function (obj) { return Object.prototype.toString.call(obj) === '[object RegExp]'; }; -var isBuffer = function isBuffer(obj) { +exports.isBuffer = function (obj) { if (obj === null || typeof obj === 'undefined') { return false; } return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj)); }; - -module.exports = { - arrayToObject: arrayToObject, - assign: assign, - compact: compact, - decode: decode, - encode: encode, - isBuffer: isBuffer, - isRegExp: isRegExp, - merge: merge -}; diff --git a/node_modules/qs/package.json b/node_modules/qs/package.json index fbdc0277c..d209537ed 100644 --- a/node_modules/qs/package.json +++ b/node_modules/qs/package.json @@ -1,27 +1,27 @@ { - "_from": "qs@~6.5.1", - "_id": "qs@6.5.2", + "_from": "qs@~6.4.0", + "_id": "qs@6.4.0", "_inBundle": false, - "_integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", + "_integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=", "_location": "/qs", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, - "raw": "qs@~6.5.1", + "raw": "qs@~6.4.0", "name": "qs", "escapedName": "qs", - "rawSpec": "~6.5.1", + "rawSpec": "~6.4.0", "saveSpec": null, - "fetchSpec": "~6.5.1" + "fetchSpec": "~6.4.0" }, "_requiredBy": [ "/request" ], - "_resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "_shasum": "cb3ae806e8740444584ef154ce8ee98d403f3e36", - "_spec": "qs@~6.5.1", - "_where": "/Users/rebecca/code/npm/node_modules/request", + "_resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", + "_shasum": "13e26d28ad6b0ffaa91312cd3bf708ed351e7233", + "_spec": "qs@~6.4.0", + "_where": "/Users/zkat/Documents/code/work/npm/node_modules/request", "bugs": { "url": "https://github.com/ljharb/qs/issues" }, @@ -37,18 +37,17 @@ "deprecated": false, "description": "A querystring parser that supports nesting and arrays, with a depth limit", "devDependencies": { - "@ljharb/eslint-config": "^12.2.1", - "browserify": "^16.2.0", + "@ljharb/eslint-config": "^11.0.0", + "browserify": "^14.1.0", "covert": "^1.1.0", - "editorconfig-tools": "^0.1.1", - "eslint": "^4.19.1", + "eslint": "^3.17.0", "evalmd": "^0.0.17", - "iconv-lite": "^0.4.21", + "iconv-lite": "^0.4.15", "mkdirp": "^0.5.1", + "parallelshell": "^2.0.0", "qs-iconv": "^1.0.4", "safe-publish-latest": "^1.1.1", - "safer-buffer": "^2.1.2", - "tape": "^4.9.0" + "tape": "^4.6.3" }, "engines": { "node": ">=0.6" @@ -69,12 +68,11 @@ "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.5.2" + "version": "6.4.0" } diff --git a/node_modules/qs/test/parse.js b/node_modules/qs/test/parse.js index 0f8fe4578..e451e91fe 100644 --- a/node_modules/qs/test/parse.js +++ b/node_modules/qs/test/parse.js @@ -2,9 +2,7 @@ var test = require('tape'); var qs = require('../'); -var utils = require('../lib/utils'); var iconv = require('iconv-lite'); -var SaferBuffer = require('safer-buffer').Buffer; test('parse()', function (t) { t.test('parses a simple string', function (st) { @@ -232,7 +230,7 @@ test('parse()', function (t) { }); t.test('parses buffers correctly', function (st) { - var b = SaferBuffer.from('test'); + var b = new Buffer('test'); st.deepEqual(qs.parse({ a: b }), { a: b }); st.end(); }); @@ -306,13 +304,6 @@ 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 }, @@ -397,33 +388,6 @@ 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'; @@ -540,35 +504,16 @@ test('parse()', function (t) { result.push(parseInt(parts[1], 16)); parts = reg.exec(str); } - return iconv.decode(SaferBuffer.from(result), 'shift_jis').toString(); + return iconv.decode(new Buffer(result), 'shift_jis').toString(); } }), { 県: '大阪府' }); 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/node_modules/qs/test/stringify.js b/node_modules/qs/test/stringify.js index 165ac621f..711dae507 100644 --- a/node_modules/qs/test/stringify.js +++ b/node_modules/qs/test/stringify.js @@ -2,9 +2,7 @@ var test = require('tape'); var qs = require('../'); -var utils = require('../lib/utils'); var iconv = require('iconv-lite'); -var SaferBuffer = require('safer-buffer').Buffer; test('stringify()', function (t) { t.test('stringifies a querystring object', function (st) { @@ -19,16 +17,6 @@ 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'); @@ -337,8 +325,8 @@ test('stringify()', function (t) { }); t.test('stringifies buffer values', function (st) { - st.equal(qs.stringify({ a: SaferBuffer.from('test') }), 'a=test'); - st.equal(qs.stringify({ a: { b: SaferBuffer.from('test') } }), 'a%5Bb%5D=test'); + st.equal(qs.stringify({ a: new Buffer('test') }), 'a=test'); + st.equal(qs.stringify({ a: { b: new Buffer('test') } }), 'a%5Bb%5D=test'); st.end(); }); @@ -464,25 +452,15 @@ 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(); }); t.test('can use custom encoder for a buffer object', { skip: typeof Buffer === 'undefined' }, function (st) { - st.equal(qs.stringify({ a: SaferBuffer.from([1]) }, { + st.equal(qs.stringify({ a: new Buffer([1]) }, { encoder: function (buffer) { if (typeof buffer === 'string') { return buffer; @@ -505,7 +483,7 @@ test('stringify()', function (t) { mutatedDate.toISOString = function () { throw new SyntaxError(); }; - st['throws'](function () { + st.throws(function () { mutatedDate.toISOString(); }, SyntaxError); st.equal( @@ -547,7 +525,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 }); }, @@ -586,12 +564,4 @@ 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/node_modules/qs/test/utils.js b/node_modules/qs/test/utils.js index eff4011a4..0721dd8ec 100644 --- a/node_modules/qs/test/utils.js +++ b/node_modules/qs/test/utils.js @@ -20,15 +20,3 @@ 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(); -}); |