diff options
Diffstat (limited to 'node_modules/qs')
-rw-r--r-- | node_modules/qs/.npmignore | 1 | ||||
-rw-r--r-- | node_modules/qs/.travis.yml | 5 | ||||
-rw-r--r-- | node_modules/qs/CHANGELOG.md | 15 | ||||
-rw-r--r-- | node_modules/qs/README.md | 15 | ||||
-rw-r--r-- | node_modules/qs/bower.json | 2 | ||||
-rw-r--r-- | node_modules/qs/component.json | 15 | ||||
-rw-r--r-- | node_modules/qs/dist/qs.js | 523 | ||||
-rw-r--r-- | node_modules/qs/lib/parse.js | 5 | ||||
-rw-r--r-- | node_modules/qs/lib/stringify.js | 35 | ||||
-rw-r--r-- | node_modules/qs/package.json | 35 | ||||
-rw-r--r-- | node_modules/qs/test/parse.js | 28 | ||||
-rw-r--r-- | node_modules/qs/test/stringify.js | 24 |
12 files changed, 653 insertions, 50 deletions
diff --git a/node_modules/qs/.npmignore b/node_modules/qs/.npmignore index 2abba8d25..7e1574dc5 100644 --- a/node_modules/qs/.npmignore +++ b/node_modules/qs/.npmignore @@ -16,4 +16,3 @@ config.json coverage.* lib-cov complexity.md -dist diff --git a/node_modules/qs/.travis.yml b/node_modules/qs/.travis.yml index f50217888..7a64dd221 100644 --- a/node_modules/qs/.travis.yml +++ b/node_modules/qs/.travis.yml @@ -2,5 +2,6 @@ language: node_js node_js: - 0.10 - - 0.12 - - iojs + - 4.0 + +sudo: false diff --git a/node_modules/qs/CHANGELOG.md b/node_modules/qs/CHANGELOG.md index 1fadc78ee..e43b1aceb 100644 --- a/node_modules/qs/CHANGELOG.md +++ b/node_modules/qs/CHANGELOG.md @@ -1,11 +1,22 @@ -## [**3.1.0**](https://github.com/hapijs/qs/issues?milestone=24&state=open) +## [**5.1.0**](https://github.com/hapijs/qs/issues?milestone=29&state=open) +- [**#117**](https://github.com/hapijs/qs/issues/117) make URI encoding stringified results optional +- [**#106**](https://github.com/hapijs/qs/issues/106) Add flag `skipNulls` to optionally skip null values in stringify + +## [**5.0.0**](https://github.com/hapijs/qs/issues?milestone=28&state=closed) +- [**#114**](https://github.com/hapijs/qs/issues/114) default allowDots to false +- [**#100**](https://github.com/hapijs/qs/issues/100) include dist to npm + +## [**4.0.0**](https://github.com/hapijs/qs/issues?milestone=26&state=closed) +- [**#98**](https://github.com/hapijs/qs/issues/98) make returning plain objects and allowing prototype overwriting properties optional + +## [**3.1.0**](https://github.com/hapijs/qs/issues?milestone=24&state=closed) - [**#89**](https://github.com/hapijs/qs/issues/89) Add option to disable "Transform dot notation to bracket notation" ## [**3.0.0**](https://github.com/hapijs/qs/issues?milestone=23&state=closed) +- [**#80**](https://github.com/hapijs/qs/issues/80) qs.parse silently drops properties - [**#77**](https://github.com/hapijs/qs/issues/77) Perf boost - [**#60**](https://github.com/hapijs/qs/issues/60) Add explicit option to disable array parsing -- [**#80**](https://github.com/hapijs/qs/issues/80) qs.parse silently drops properties - [**#74**](https://github.com/hapijs/qs/issues/74) Bad parse when turning array into object - [**#81**](https://github.com/hapijs/qs/issues/81) Add a `filter` option - [**#68**](https://github.com/hapijs/qs/issues/68) Fixed issue with recursion and passing strings into objects. diff --git a/node_modules/qs/README.md b/node_modules/qs/README.md index 48a0de97f..369f38567 100644 --- a/node_modules/qs/README.md +++ b/node_modules/qs/README.md @@ -23,7 +23,7 @@ var str = Qs.stringify(obj); // 'a=c' Qs.parse(string, [options]); ``` -**qs** allows you to create nested objects within your query strings, by surrounding the name of sub-keys with square brackets `[]`, or prefixing the sub-key with a dot `.`. +**qs** allows you to create nested objects within your query strings, by surrounding the name of sub-keys with square brackets `[]`. For example, the string `'foo[bar]=baz'` converts to: ```javascript @@ -118,11 +118,11 @@ Qs.parse('a=b;c=d,e=f', { delimiter: /[;,]/ }); // { a: 'b', c: 'd', e: 'f' } ``` -Option `allowDots` can be used to disable dot notation: +Option `allowDots` can be used to enable dot notation: ```javascript -Qs.parse('a.b=c', { allowDots: false }); -// { 'a.b': 'c' } } +Qs.parse('a.b=c', { allowDots: true }); +// { a: { b: 'c' } } ``` ### Parsing Arrays @@ -315,3 +315,10 @@ Qs.parse('a&b=', { strictNullHandling: true }); // { a: null, b: '' } ``` + +To completely skip rendering keys with `null` values, use the `skipNulls` flag: + +```javascript +qs.stringify({ a: 'b', c: null}, { skipNulls: true }) +// 'a=b' +``` diff --git a/node_modules/qs/bower.json b/node_modules/qs/bower.json index ffd0641d8..53a70d0c9 100644 --- a/node_modules/qs/bower.json +++ b/node_modules/qs/bower.json @@ -1,7 +1,7 @@ { "name": "qs", "main": "dist/qs.js", - "version": "3.0.0", + "version": "5.1.0", "homepage": "https://github.com/hapijs/qs", "authors": [ "Nathan LaFreniere <quitlahok@gmail.com>" diff --git a/node_modules/qs/component.json b/node_modules/qs/component.json new file mode 100644 index 000000000..1a1f72c7a --- /dev/null +++ b/node_modules/qs/component.json @@ -0,0 +1,15 @@ +{ + "name": "qs", + "repository": "hapijs/qs", + "description": "query-string parser / stringifier with nesting support", + "version": "5.1.0", + "keywords": ["querystring", "query", "parser"], + "main": "lib/index.js", + "scripts": [ + "lib/index.js", + "lib/parse.js", + "lib/stringify.js", + "lib/utils.js" + ], + "license": "BSD-3-Clause" +} diff --git a/node_modules/qs/dist/qs.js b/node_modules/qs/dist/qs.js new file mode 100644 index 000000000..2b9fec301 --- /dev/null +++ b/node_modules/qs/dist/qs.js @@ -0,0 +1,523 @@ +(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){ +// Load modules + +var Stringify = require('./stringify'); +var Parse = require('./parse'); + + +// Declare internals + +var internals = {}; + + +module.exports = { + stringify: Stringify, + parse: Parse +}; + +},{"./parse":2,"./stringify":3}],2:[function(require,module,exports){ +// Load modules + +var Utils = require('./utils'); + + +// Declare internals + +var internals = { + delimiter: '&', + depth: 5, + arrayLimit: 20, + parameterLimit: 1000, + strictNullHandling: false, + plainObjects: false, + allowPrototypes: false, + allowDots: false +}; + + +internals.parseValues = function (str, options) { + + var obj = {}; + var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit); + + for (var i = 0, il = parts.length; i < il; ++i) { + var part = parts[i]; + var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1; + + if (pos === -1) { + obj[Utils.decode(part)] = ''; + + if (options.strictNullHandling) { + obj[Utils.decode(part)] = null; + } + } + else { + var key = Utils.decode(part.slice(0, pos)); + var val = Utils.decode(part.slice(pos + 1)); + + if (!Object.prototype.hasOwnProperty.call(obj, key)) { + obj[key] = val; + } + else { + obj[key] = [].concat(obj[key]).concat(val); + } + } + } + + return obj; +}; + + +internals.parseObject = function (chain, val, options) { + + if (!chain.length) { + return val; + } + + var root = chain.shift(); + + var obj; + if (root === '[]') { + obj = []; + obj = obj.concat(internals.parseObject(chain, val, options)); + } + else { + obj = options.plainObjects ? Object.create(null) : {}; + var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root; + var index = parseInt(cleanRoot, 10); + var indexString = '' + index; + if (!isNaN(index) && + root !== cleanRoot && + indexString === cleanRoot && + index >= 0 && + (options.parseArrays && + index <= options.arrayLimit)) { + + obj = []; + obj[index] = internals.parseObject(chain, val, options); + } + else { + obj[cleanRoot] = internals.parseObject(chain, val, options); + } + } + + return obj; +}; + + +internals.parseKeys = function (key, val, options) { + + if (!key) { + return; + } + + // Transform dot notation to bracket notation + + if (options.allowDots) { + key = key.replace(/\.([^\.\[]+)/g, '[$1]'); + } + + // The regex chunks + + var parent = /^([^\[\]]*)/; + var child = /(\[[^\[\]]*\])/g; + + // Get the parent + + var segment = parent.exec(key); + + // Stash the parent if it exists + + var keys = []; + if (segment[1]) { + // If we aren't using plain objects, optionally prefix keys + // that would overwrite object prototype properties + if (!options.plainObjects && + Object.prototype.hasOwnProperty(segment[1])) { + + if (!options.allowPrototypes) { + return; + } + } + + keys.push(segment[1]); + } + + // Loop through children appending to the array until we hit depth + + var i = 0; + while ((segment = child.exec(key)) !== null && i < options.depth) { + + ++i; + if (!options.plainObjects && + Object.prototype.hasOwnProperty(segment[1].replace(/\[|\]/g, ''))) { + + if (!options.allowPrototypes) { + continue; + } + } + keys.push(segment[1]); + } + + // If there's a remainder, just add whatever is left + + if (segment) { + keys.push('[' + key.slice(segment.index) + ']'); + } + + return internals.parseObject(keys, val, options); +}; + + +module.exports = function (str, options) { + + options = options || {}; + options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : internals.delimiter; + options.depth = typeof options.depth === 'number' ? options.depth : internals.depth; + options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : internals.arrayLimit; + options.parseArrays = options.parseArrays !== false; + options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : internals.allowDots; + options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : internals.plainObjects; + options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : internals.allowPrototypes; + options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : internals.parameterLimit; + options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : internals.strictNullHandling; + + if (str === '' || + str === null || + typeof str === 'undefined') { + + return options.plainObjects ? Object.create(null) : {}; + } + + var tempObj = typeof str === 'string' ? internals.parseValues(str, options) : str; + var obj = options.plainObjects ? Object.create(null) : {}; + + // Iterate over the keys and setup the new object + + var keys = Object.keys(tempObj); + for (var i = 0, il = keys.length; i < il; ++i) { + var key = keys[i]; + var newObj = internals.parseKeys(key, tempObj[key], options); + obj = Utils.merge(obj, newObj, options); + } + + return Utils.compact(obj); +}; + +},{"./utils":4}],3:[function(require,module,exports){ +// Load modules + +var Utils = require('./utils'); + + +// Declare internals + +var internals = { + delimiter: '&', + arrayPrefixGenerators: { + brackets: function (prefix, key) { + + return prefix + '[]'; + }, + indices: function (prefix, key) { + + return prefix + '[' + key + ']'; + }, + repeat: function (prefix, key) { + + return prefix; + } + }, + strictNullHandling: false +}; + + +internals.stringify = function (obj, prefix, generateArrayPrefix, strictNullHandling, filter) { + + if (typeof filter === 'function') { + obj = filter(prefix, obj); + } + else if (Utils.isBuffer(obj)) { + obj = obj.toString(); + } + else if (obj instanceof Date) { + obj = obj.toISOString(); + } + else if (obj === null) { + if (strictNullHandling) { + return Utils.encode(prefix); + } + + obj = ''; + } + + if (typeof obj === 'string' || + typeof obj === 'number' || + typeof obj === 'boolean') { + + return [Utils.encode(prefix) + '=' + Utils.encode(obj)]; + } + + var values = []; + + if (typeof obj === 'undefined') { + return values; + } + + var objKeys = Array.isArray(filter) ? filter : Object.keys(obj); + for (var i = 0, il = objKeys.length; i < il; ++i) { + var key = objKeys[i]; + + if (Array.isArray(obj)) { + values = values.concat(internals.stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix, strictNullHandling, filter)); + } + else { + values = values.concat(internals.stringify(obj[key], prefix + '[' + key + ']', generateArrayPrefix, strictNullHandling, filter)); + } + } + + return values; +}; + + +module.exports = function (obj, options) { + + options = options || {}; + var delimiter = typeof options.delimiter === 'undefined' ? internals.delimiter : options.delimiter; + var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : internals.strictNullHandling; + var objKeys; + var filter; + if (typeof options.filter === 'function') { + filter = options.filter; + obj = filter('', obj); + } + else if (Array.isArray(options.filter)) { + objKeys = filter = options.filter; + } + + var keys = []; + + if (typeof obj !== 'object' || + obj === null) { + + return ''; + } + + var arrayFormat; + if (options.arrayFormat in internals.arrayPrefixGenerators) { + arrayFormat = options.arrayFormat; + } + else if ('indices' in options) { + arrayFormat = options.indices ? 'indices' : 'repeat'; + } + else { + arrayFormat = 'indices'; + } + + var generateArrayPrefix = internals.arrayPrefixGenerators[arrayFormat]; + + if (!objKeys) { + objKeys = Object.keys(obj); + } + for (var i = 0, il = objKeys.length; i < il; ++i) { + var key = objKeys[i]; + keys = keys.concat(internals.stringify(obj[key], key, generateArrayPrefix, strictNullHandling, filter)); + } + + return keys.join(delimiter); +}; + +},{"./utils":4}],4:[function(require,module,exports){ +// Load modules + + +// Declare internals + +var internals = {}; +internals.hexTable = new Array(256); +for (var h = 0; h < 256; ++h) { + internals.hexTable[h] = '%' + ((h < 16 ? '0' : '') + h.toString(16)).toUpperCase(); +} + + +exports.arrayToObject = function (source, options) { + + var obj = options.plainObjects ? Object.create(null) : {}; + for (var i = 0, il = source.length; i < il; ++i) { + if (typeof source[i] !== 'undefined') { + + obj[i] = source[i]; + } + } + + return obj; +}; + + +exports.merge = function (target, source, options) { + + if (!source) { + return target; + } + + if (typeof source !== 'object') { + if (Array.isArray(target)) { + target.push(source); + } + else if (typeof target === 'object') { + target[source] = true; + } + else { + target = [target, source]; + } + + return target; + } + + if (typeof target !== 'object') { + target = [target].concat(source); + return target; + } + + if (Array.isArray(target) && + !Array.isArray(source)) { + + target = exports.arrayToObject(target, options); + } + + var keys = Object.keys(source); + for (var k = 0, kl = keys.length; k < kl; ++k) { + var key = keys[k]; + var value = source[key]; + + if (!Object.prototype.hasOwnProperty.call(target, key)) { + target[key] = value; + } + else { + target[key] = exports.merge(target[key], value, options); + } + } + + return target; +}; + + +exports.decode = function (str) { + + try { + return decodeURIComponent(str.replace(/\+/g, ' ')); + } catch (e) { + return 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) { + return str; + } + + if (typeof str !== 'string') { + str = '' + str; + } + + var out = ''; + for (var i = 0, il = str.length; i < il; ++i) { + var c = str.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 + + out += str[i]; + continue; + } + + if (c < 0x80) { + out += internals.hexTable[c]; + continue; + } + + if (c < 0x800) { + out += internals.hexTable[0xC0 | (c >> 6)] + internals.hexTable[0x80 | (c & 0x3F)]; + continue; + } + + if (c < 0xD800 || c >= 0xE000) { + out += internals.hexTable[0xE0 | (c >> 12)] + internals.hexTable[0x80 | ((c >> 6) & 0x3F)] + internals.hexTable[0x80 | (c & 0x3F)]; + continue; + } + + ++i; + c = 0x10000 + (((c & 0x3FF) << 10) | (str.charCodeAt(i) & 0x3FF)); + out += internals.hexTable[0xF0 | (c >> 18)] + internals.hexTable[0x80 | ((c >> 12) & 0x3F)] + internals.hexTable[0x80 | ((c >> 6) & 0x3F)] + internals.hexTable[0x80 | (c & 0x3F)]; + } + + return out; +}; + +exports.compact = function (obj, refs) { + + if (typeof obj !== 'object' || + obj === null) { + + return obj; + } + + refs = refs || []; + var lookup = refs.indexOf(obj); + if (lookup !== -1) { + return refs[lookup]; + } + + refs.push(obj); + + if (Array.isArray(obj)) { + var compacted = []; + + for (var i = 0, il = obj.length; i < il; ++i) { + if (typeof obj[i] !== 'undefined') { + compacted.push(obj[i]); + } + } + + return compacted; + } + + var keys = Object.keys(obj); + for (i = 0, il = keys.length; i < il; ++i) { + var key = keys[i]; + obj[key] = exports.compact(obj[key], refs); + } + + return obj; +}; + + +exports.isRegExp = function (obj) { + + return Object.prototype.toString.call(obj) === '[object RegExp]'; +}; + + +exports.isBuffer = function (obj) { + + if (obj === null || + typeof obj === 'undefined') { + + return false; + } + + return !!(obj.constructor && + obj.constructor.isBuffer && + obj.constructor.isBuffer(obj)); +}; + +},{}]},{},[1])(1) +});
\ No newline at end of file diff --git a/node_modules/qs/lib/parse.js b/node_modules/qs/lib/parse.js index e7c56c5ce..4a2137efa 100644 --- a/node_modules/qs/lib/parse.js +++ b/node_modules/qs/lib/parse.js @@ -12,7 +12,8 @@ var internals = { parameterLimit: 1000, strictNullHandling: false, plainObjects: false, - allowPrototypes: false + allowPrototypes: false, + allowDots: false }; @@ -157,7 +158,7 @@ module.exports = function (str, options) { options.depth = typeof options.depth === 'number' ? options.depth : internals.depth; options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : internals.arrayLimit; options.parseArrays = options.parseArrays !== false; - options.allowDots = options.allowDots !== false; + options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : internals.allowDots; options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : internals.plainObjects; options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : internals.allowPrototypes; options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : internals.parameterLimit; diff --git a/node_modules/qs/lib/stringify.js b/node_modules/qs/lib/stringify.js index 7414284c5..6a73004c4 100644 --- a/node_modules/qs/lib/stringify.js +++ b/node_modules/qs/lib/stringify.js @@ -21,11 +21,13 @@ var internals = { return prefix; } }, - strictNullHandling: false + strictNullHandling: false, + skipNulls: false, + encode: true }; -internals.stringify = function (obj, prefix, generateArrayPrefix, strictNullHandling, filter) { +internals.stringify = function (obj, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encode, filter) { if (typeof filter === 'function') { obj = filter(prefix, obj); @@ -38,7 +40,7 @@ internals.stringify = function (obj, prefix, generateArrayPrefix, strictNullHand } else if (obj === null) { if (strictNullHandling) { - return Utils.encode(prefix); + return encode ? Utils.encode(prefix) : prefix; } obj = ''; @@ -48,7 +50,10 @@ internals.stringify = function (obj, prefix, generateArrayPrefix, strictNullHand typeof obj === 'number' || typeof obj === 'boolean') { - return [Utils.encode(prefix) + '=' + Utils.encode(obj)]; + if (encode) { + return [Utils.encode(prefix) + '=' + Utils.encode(obj)]; + } + return [prefix + '=' + obj]; } var values = []; @@ -61,11 +66,17 @@ internals.stringify = function (obj, prefix, generateArrayPrefix, strictNullHand for (var i = 0, il = objKeys.length; i < il; ++i) { var key = objKeys[i]; + if (skipNulls && + obj[key] === null) { + + continue; + } + if (Array.isArray(obj)) { - values = values.concat(internals.stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix, strictNullHandling, filter)); + values = values.concat(internals.stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix, strictNullHandling, skipNulls, encode, filter)); } else { - values = values.concat(internals.stringify(obj[key], prefix + '[' + key + ']', generateArrayPrefix, strictNullHandling, filter)); + values = values.concat(internals.stringify(obj[key], prefix + '[' + key + ']', generateArrayPrefix, strictNullHandling, skipNulls, encode, filter)); } } @@ -78,6 +89,8 @@ module.exports = function (obj, options) { options = options || {}; var delimiter = typeof options.delimiter === 'undefined' ? internals.delimiter : options.delimiter; var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : internals.strictNullHandling; + var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : internals.skipNulls; + var encode = typeof options.encode === 'boolean' ? options.encode : internals.encode; var objKeys; var filter; if (typeof options.filter === 'function') { @@ -112,9 +125,17 @@ module.exports = function (obj, options) { if (!objKeys) { objKeys = Object.keys(obj); } + for (var i = 0, il = objKeys.length; i < il; ++i) { var key = objKeys[i]; - keys = keys.concat(internals.stringify(obj[key], key, generateArrayPrefix, strictNullHandling, filter)); + + if (skipNulls && + obj[key] === null) { + + continue; + } + + keys = keys.concat(internals.stringify(obj[key], key, generateArrayPrefix, strictNullHandling, skipNulls, encode, filter)); } return keys.join(delimiter); diff --git a/node_modules/qs/package.json b/node_modules/qs/package.json index ed8ba494a..c2aba945d 100644 --- a/node_modules/qs/package.json +++ b/node_modules/qs/package.json @@ -1,36 +1,36 @@ { "_args": [ [ - "qs@~4.0.0", + "qs@~5.1.0", "/Users/rebecca/code/npm/node_modules/request" ] ], - "_from": "qs@>=4.0.0 <4.1.0", - "_id": "qs@4.0.0", + "_from": "qs@>=5.1.0 <5.2.0", + "_id": "qs@5.1.0", "_inCache": true, "_location": "/qs", - "_nodeVersion": "0.12.4", + "_nodeVersion": "0.12.7", "_npmUser": { "email": "quitlahok@gmail.com", "name": "nlf" }, - "_npmVersion": "2.12.0", + "_npmVersion": "2.14.1", "_phantomChildren": {}, "_requested": { "name": "qs", - "raw": "qs@~4.0.0", - "rawSpec": "~4.0.0", + "raw": "qs@~5.1.0", + "rawSpec": "~5.1.0", "scope": null, - "spec": ">=4.0.0 <4.1.0", + "spec": ">=5.1.0 <5.2.0", "type": "range" }, "_requiredBy": [ "/request" ], - "_resolved": "https://registry.npmjs.org/qs/-/qs-4.0.0.tgz", - "_shasum": "c31d9b74ec27df75e543a86c78728ed8d4623607", + "_resolved": "https://registry.npmjs.org/qs/-/qs-5.1.0.tgz", + "_shasum": "4d932e5c7ea411cca76a312d39a606200fd50cd9", "_shrinkwrap": null, - "_spec": "qs@~4.0.0", + "_spec": "qs@~5.1.0", "_where": "/Users/rebecca/code/npm/node_modules/request", "bugs": { "url": "https://github.com/hapijs/qs/issues" @@ -44,11 +44,13 @@ }, "directories": {}, "dist": { - "shasum": "c31d9b74ec27df75e543a86c78728ed8d4623607", - "tarball": "http://registry.npmjs.org/qs/-/qs-4.0.0.tgz" + "shasum": "4d932e5c7ea411cca76a312d39a606200fd50cd9", + "tarball": "http://registry.npmjs.org/qs/-/qs-5.1.0.tgz" }, - "gitHead": "e573dd08eae6cce30d2202704691a102dfa3782a", + "engines": ">=0.10.40", + "gitHead": "9e9759ec5be2dd99ce90961bbff47075cd5a8160", "homepage": "https://github.com/hapijs/qs", + "installable": true, "keywords": [ "qs", "querystring" @@ -74,7 +76,8 @@ "scripts": { "dist": "browserify --standalone Qs lib/index.js > dist/qs.js", "test": "lab -a code -t 100 -L", - "test-cov-html": "lab -a code -r html -o coverage.html" + "test-cov-html": "lab -a code -r html -o coverage.html", + "test-tap": "lab -a code -r tap -o tests.tap" }, - "version": "4.0.0" + "version": "5.1.0" } diff --git a/node_modules/qs/test/parse.js b/node_modules/qs/test/parse.js index a19d76457..679f19747 100644 --- a/node_modules/qs/test/parse.js +++ b/node_modules/qs/test/parse.js @@ -47,10 +47,10 @@ describe('parse()', function () { done(); }); - it('allows disabling dot notation', function (done) { + it('allows enabling dot notation', function (done) { - expect(Qs.parse('a.b=c')).to.deep.equal({ a: { b: 'c' } }); - expect(Qs.parse('a.b=c', { allowDots: false })).to.deep.equal({ 'a.b': 'c' }); + expect(Qs.parse('a.b=c')).to.deep.equal({ 'a.b': 'c' }); + expect(Qs.parse('a.b=c', { allowDots: true })).to.deep.equal({ a: { b: 'c' } }); done(); }); @@ -175,16 +175,16 @@ describe('parse()', function () { it('transforms arrays to objects (dot notation)', function (done) { - expect(Qs.parse('foo[0].baz=bar&fool.bad=baz')).to.deep.equal({ foo: [{ baz: 'bar' }], fool: { bad: 'baz' } }); - expect(Qs.parse('foo[0].baz=bar&fool.bad.boo=baz')).to.deep.equal({ foo: [{ baz: 'bar' }], fool: { bad: { boo: 'baz' } } }); - expect(Qs.parse('foo[0][0].baz=bar&fool.bad=baz')).to.deep.equal({ foo: [[{ baz: 'bar' }]], fool: { bad: 'baz' } }); - expect(Qs.parse('foo[0].baz[0]=15&foo[0].bar=2')).to.deep.equal({ foo: [{ baz: ['15'], bar: '2' }] }); - expect(Qs.parse('foo[0].baz[0]=15&foo[0].baz[1]=16&foo[0].bar=2')).to.deep.equal({ foo: [{ baz: ['15', '16'], bar: '2' }] }); - expect(Qs.parse('foo.bad=baz&foo[0]=bar')).to.deep.equal({ foo: { bad: 'baz', '0': 'bar' } }); - expect(Qs.parse('foo.bad=baz&foo[]=bar')).to.deep.equal({ foo: { bad: 'baz', '0': 'bar' } }); - expect(Qs.parse('foo[]=bar&foo.bad=baz')).to.deep.equal({ foo: { '0': 'bar', bad: 'baz' } }); - expect(Qs.parse('foo.bad=baz&foo[]=bar&foo[]=foo')).to.deep.equal({ foo: { bad: 'baz', '0': 'bar', '1': 'foo' } }); - expect(Qs.parse('foo[0].a=a&foo[0].b=b&foo[1].a=aa&foo[1].b=bb')).to.deep.equal({ foo: [{ a: 'a', b: 'b' }, { a: 'aa', b: 'bb' }] }); + expect(Qs.parse('foo[0].baz=bar&fool.bad=baz', { allowDots: true })).to.deep.equal({ foo: [{ baz: 'bar' }], fool: { bad: 'baz' } }); + expect(Qs.parse('foo[0].baz=bar&fool.bad.boo=baz', { allowDots: true })).to.deep.equal({ foo: [{ baz: 'bar' }], fool: { bad: { boo: 'baz' } } }); + expect(Qs.parse('foo[0][0].baz=bar&fool.bad=baz', { allowDots: true })).to.deep.equal({ foo: [[{ baz: 'bar' }]], fool: { bad: 'baz' } }); + expect(Qs.parse('foo[0].baz[0]=15&foo[0].bar=2', { allowDots: true })).to.deep.equal({ foo: [{ baz: ['15'], bar: '2' }] }); + expect(Qs.parse('foo[0].baz[0]=15&foo[0].baz[1]=16&foo[0].bar=2', { allowDots: true })).to.deep.equal({ foo: [{ baz: ['15', '16'], bar: '2' }] }); + expect(Qs.parse('foo.bad=baz&foo[0]=bar', { allowDots: true })).to.deep.equal({ foo: { bad: 'baz', '0': 'bar' } }); + expect(Qs.parse('foo.bad=baz&foo[]=bar', { allowDots: true })).to.deep.equal({ foo: { bad: 'baz', '0': 'bar' } }); + expect(Qs.parse('foo[]=bar&foo.bad=baz', { allowDots: true })).to.deep.equal({ foo: { '0': 'bar', bad: 'baz' } }); + expect(Qs.parse('foo.bad=baz&foo[]=bar&foo[]=foo', { allowDots: true })).to.deep.equal({ foo: { bad: 'baz', '0': 'bar', '1': 'foo' } }); + expect(Qs.parse('foo[0].a=a&foo[0].b=b&foo[1].a=aa&foo[1].b=bb', { allowDots: true })).to.deep.equal({ foo: [{ a: 'a', b: 'b' }, { a: 'aa', b: 'bb' }] }); done(); }); @@ -372,7 +372,7 @@ describe('parse()', function () { } }; - var result = Qs.parse(input); + var result = Qs.parse(input, { allowDots: true }); expect(result).to.deep.equal(expected); done(); diff --git a/node_modules/qs/test/stringify.js b/node_modules/qs/test/stringify.js index 48b7803f7..5163700f3 100644 --- a/node_modules/qs/test/stringify.js +++ b/node_modules/qs/test/stringify.js @@ -47,6 +47,19 @@ describe('stringify()', function () { done(); }); + it('omits nulls when asked', function (done) { + + expect(Qs.stringify({ a: 'b', c: null }, { skipNulls: true })).to.equal('a=b'); + done(); + }); + + + it('omits nested nulls when asked', function (done) { + + expect(Qs.stringify({ a: { b: 'c', d: null } }, { skipNulls: true })).to.equal('a%5Bb%5D=c'); + done(); + }); + it('omits array indices when asked', function (done) { expect(Qs.stringify({ a: ['b', 'c', 'd'] }, { indices: false })).to.equal('a=b&a=c&a=d'); @@ -216,8 +229,9 @@ describe('stringify()', function () { var tempBuffer = global.Buffer; delete global.Buffer; - expect(Qs.stringify({ a: 'b', c: 'd' })).to.equal('a=b&c=d'); + var result = Qs.stringify({ a: 'b', c: 'd' }); global.Buffer = tempBuffer; + expect(result).to.equal('a=b&c=d'); done(); }); @@ -256,4 +270,12 @@ describe('stringify()', function () { done(); }); + + it('can disable uri encoding', function (done) { + + expect(Qs.stringify({ a: 'b' }, { encode: false })).to.equal('a=b'); + expect(Qs.stringify({ a: { b: 'c' } }, { encode: false })).to.equal('a[b]=c'); + expect(Qs.stringify({ a: 'b', c: null }, { strictNullHandling: true, encode: false })).to.equal('a=b&c'); + done(); + }); }); |