mirror of
https://github.com/bodyrep/DemoApp.git
synced 2026-03-14 17:05:56 +00:00
migrating repo to Bodyrep org
This commit is contained in:
6
node_modules/qs/.gitmodules
generated
vendored
Normal file
6
node_modules/qs/.gitmodules
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
[submodule "support/expresso"]
|
||||
path = support/expresso
|
||||
url = git://github.com/visionmedia/expresso.git
|
||||
[submodule "support/should"]
|
||||
path = support/should
|
||||
url = git://github.com/visionmedia/should.js.git
|
||||
1
node_modules/qs/.npmignore
generated
vendored
Normal file
1
node_modules/qs/.npmignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
4
node_modules/qs/.travis.yml
generated
vendored
Normal file
4
node_modules/qs/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.6
|
||||
- 0.4
|
||||
94
node_modules/qs/History.md
generated
vendored
Normal file
94
node_modules/qs/History.md
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
|
||||
0.5.3 2012-12-09
|
||||
==================
|
||||
|
||||
* add info to component.json
|
||||
* remove regular client-side ./querystring.js, fix component.json support
|
||||
|
||||
0.5.2 / 2012-11-14
|
||||
==================
|
||||
|
||||
* fix uri encoding of non-plain object string values
|
||||
|
||||
0.5.1 / 2012-09-18
|
||||
==================
|
||||
|
||||
* fix encoded `=`. Closes #43
|
||||
|
||||
0.5.0 / 2012-05-04
|
||||
==================
|
||||
|
||||
* Added component support
|
||||
|
||||
0.4.2 / 2012-02-08
|
||||
==================
|
||||
|
||||
* Fixed: ensure objects are created when appropriate not arrays [aheckmann]
|
||||
|
||||
0.4.1 / 2012-01-26
|
||||
==================
|
||||
|
||||
* Fixed stringify()ing numbers. Closes #23
|
||||
|
||||
0.4.0 / 2011-11-21
|
||||
==================
|
||||
|
||||
* Allow parsing of an existing object (for `bodyParser()`) [jackyz]
|
||||
* Replaced expresso with mocha
|
||||
|
||||
0.3.2 / 2011-11-08
|
||||
==================
|
||||
|
||||
* Fixed global variable leak
|
||||
|
||||
0.3.1 / 2011-08-17
|
||||
==================
|
||||
|
||||
* Added `try/catch` around malformed uri components
|
||||
* Add test coverage for Array native method bleed-though
|
||||
|
||||
0.3.0 / 2011-07-19
|
||||
==================
|
||||
|
||||
* Allow `array[index]` and `object[property]` syntaxes [Aria Stewart]
|
||||
|
||||
0.2.0 / 2011-06-29
|
||||
==================
|
||||
|
||||
* Added `qs.stringify()` [Cory Forsyth]
|
||||
|
||||
0.1.0 / 2011-04-13
|
||||
==================
|
||||
|
||||
* Added jQuery-ish array support
|
||||
|
||||
0.0.7 / 2011-03-13
|
||||
==================
|
||||
|
||||
* Fixed; handle empty string and `== null` in `qs.parse()` [dmit]
|
||||
allows for convenient `qs.parse(url.parse(str).query)`
|
||||
|
||||
0.0.6 / 2011-02-14
|
||||
==================
|
||||
|
||||
* Fixed; support for implicit arrays
|
||||
|
||||
0.0.4 / 2011-02-09
|
||||
==================
|
||||
|
||||
* Fixed `+` as a space
|
||||
|
||||
0.0.3 / 2011-02-08
|
||||
==================
|
||||
|
||||
* Fixed case when right-hand value contains "]"
|
||||
|
||||
0.0.2 / 2011-02-07
|
||||
==================
|
||||
|
||||
* Fixed "=" presence in key
|
||||
|
||||
0.0.1 / 2011-02-07
|
||||
==================
|
||||
|
||||
* Initial release
|
||||
6
node_modules/qs/Makefile
generated
vendored
Normal file
6
node_modules/qs/Makefile
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
test:
|
||||
@./node_modules/.bin/mocha \
|
||||
--ui bdd
|
||||
|
||||
.PHONY: test
|
||||
58
node_modules/qs/Readme.md
generated
vendored
Normal file
58
node_modules/qs/Readme.md
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
# node-querystring
|
||||
|
||||
query string parser for node and the browser supporting nesting, as it was removed from `0.3.x`, so this library provides the previous and commonly desired behaviour (and twice as fast). Used by [express](http://expressjs.com), [connect](http://senchalabs.github.com/connect) and others.
|
||||
|
||||
## Installation
|
||||
|
||||
$ npm install qs
|
||||
|
||||
## Examples
|
||||
|
||||
```js
|
||||
var qs = require('qs');
|
||||
|
||||
qs.parse('user[name][first]=Tobi&user[email]=tobi@learnboost.com');
|
||||
// => { user: { name: { first: 'Tobi' }, email: 'tobi@learnboost.com' } }
|
||||
|
||||
qs.stringify({ user: { name: 'Tobi', email: 'tobi@learnboost.com' }})
|
||||
// => user[name]=Tobi&user[email]=tobi%40learnboost.com
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
Install dev dependencies:
|
||||
|
||||
$ npm install -d
|
||||
|
||||
and execute:
|
||||
|
||||
$ make test
|
||||
|
||||
browser:
|
||||
|
||||
$ open test/browser/index.html
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2010 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
17
node_modules/qs/benchmark.js
generated
vendored
Normal file
17
node_modules/qs/benchmark.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
var qs = require('./');
|
||||
|
||||
var times = 100000
|
||||
, start = new Date
|
||||
, n = times;
|
||||
|
||||
console.log('times: %d', times);
|
||||
|
||||
while (n--) qs.parse('foo=bar');
|
||||
console.log('simple: %dms', new Date - start);
|
||||
|
||||
var start = new Date
|
||||
, n = times;
|
||||
|
||||
while (n--) qs.parse('user[name][first]=tj&user[name][last]=holowaychuk');
|
||||
console.log('nested: %dms', new Date - start);
|
||||
9
node_modules/qs/component.json
generated
vendored
Normal file
9
node_modules/qs/component.json
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "querystring",
|
||||
"repo": "visionmedia/node-querystring",
|
||||
"description": "query-string parser / stringifier with nesting support",
|
||||
"version": "0.5.3",
|
||||
"keywords": ["querystring", "query", "parser"],
|
||||
"scripts": ["index.js"],
|
||||
"license": "MIT"
|
||||
}
|
||||
51
node_modules/qs/examples.js
generated
vendored
Normal file
51
node_modules/qs/examples.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var qs = require('./');
|
||||
|
||||
var obj = qs.parse('foo');
|
||||
console.log(obj)
|
||||
|
||||
var obj = qs.parse('foo=bar=baz');
|
||||
console.log(obj)
|
||||
|
||||
var obj = qs.parse('users[]');
|
||||
console.log(obj)
|
||||
|
||||
var obj = qs.parse('name=tj&email=tj@vision-media.ca');
|
||||
console.log(obj)
|
||||
|
||||
var obj = qs.parse('users[]=tj&users[]=tobi&users[]=jane');
|
||||
console.log(obj)
|
||||
|
||||
var obj = qs.parse('user[name][first]=tj&user[name][last]=holowaychuk');
|
||||
console.log(obj)
|
||||
|
||||
var obj = qs.parse('users[][name][first]=tj&users[][name][last]=holowaychuk');
|
||||
console.log(obj)
|
||||
|
||||
var obj = qs.parse('a=a&a=b&a=c');
|
||||
console.log(obj)
|
||||
|
||||
var obj = qs.parse('user[tj]=tj&user[tj]=TJ');
|
||||
console.log(obj)
|
||||
|
||||
var obj = qs.parse('user[names]=tj&user[names]=TJ&user[names]=Tyler');
|
||||
console.log(obj)
|
||||
|
||||
var obj = qs.parse('user[name][first]=tj&user[name][first]=TJ');
|
||||
console.log(obj)
|
||||
|
||||
var obj = qs.parse('user[0]=tj&user[1]=TJ');
|
||||
console.log(obj)
|
||||
|
||||
var obj = qs.parse('user[0]=tj&user[]=TJ');
|
||||
console.log(obj)
|
||||
|
||||
var obj = qs.parse('user[0]=tj&user[foo]=TJ');
|
||||
console.log(obj)
|
||||
|
||||
var str = qs.stringify({ user: { name: 'Tobi', email: 'tobi@learnboost.com' }});
|
||||
console.log(str);
|
||||
262
node_modules/qs/index.js
generated
vendored
Normal file
262
node_modules/qs/index.js
generated
vendored
Normal file
@@ -0,0 +1,262 @@
|
||||
|
||||
/**
|
||||
* Object#toString() ref for stringify().
|
||||
*/
|
||||
|
||||
var toString = Object.prototype.toString;
|
||||
|
||||
/**
|
||||
* Cache non-integer test regexp.
|
||||
*/
|
||||
|
||||
var isint = /^[0-9]+$/;
|
||||
|
||||
function promote(parent, key) {
|
||||
if (parent[key].length == 0) return parent[key] = {};
|
||||
var t = {};
|
||||
for (var i in parent[key]) t[i] = parent[key][i];
|
||||
parent[key] = t;
|
||||
return t;
|
||||
}
|
||||
|
||||
function parse(parts, parent, key, val) {
|
||||
var part = parts.shift();
|
||||
// end
|
||||
if (!part) {
|
||||
if (Array.isArray(parent[key])) {
|
||||
parent[key].push(val);
|
||||
} else if ('object' == typeof parent[key]) {
|
||||
parent[key] = val;
|
||||
} else if ('undefined' == typeof parent[key]) {
|
||||
parent[key] = val;
|
||||
} else {
|
||||
parent[key] = [parent[key], val];
|
||||
}
|
||||
// array
|
||||
} else {
|
||||
var obj = parent[key] = parent[key] || [];
|
||||
if (']' == part) {
|
||||
if (Array.isArray(obj)) {
|
||||
if ('' != val) obj.push(val);
|
||||
} else if ('object' == typeof obj) {
|
||||
obj[Object.keys(obj).length] = val;
|
||||
} else {
|
||||
obj = parent[key] = [parent[key], val];
|
||||
}
|
||||
// prop
|
||||
} else if (~part.indexOf(']')) {
|
||||
part = part.substr(0, part.length - 1);
|
||||
if (!isint.test(part) && Array.isArray(obj)) obj = promote(parent, key);
|
||||
parse(parts, obj, part, val);
|
||||
// key
|
||||
} else {
|
||||
if (!isint.test(part) && Array.isArray(obj)) obj = promote(parent, key);
|
||||
parse(parts, obj, part, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge parent key/val pair.
|
||||
*/
|
||||
|
||||
function merge(parent, key, val){
|
||||
if (~key.indexOf(']')) {
|
||||
var parts = key.split('[')
|
||||
, len = parts.length
|
||||
, last = len - 1;
|
||||
parse(parts, parent, 'base', val);
|
||||
// optimize
|
||||
} else {
|
||||
if (!isint.test(key) && Array.isArray(parent.base)) {
|
||||
var t = {};
|
||||
for (var k in parent.base) t[k] = parent.base[k];
|
||||
parent.base = t;
|
||||
}
|
||||
set(parent.base, key, val);
|
||||
}
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the given obj.
|
||||
*/
|
||||
|
||||
function parseObject(obj){
|
||||
var ret = { base: {} };
|
||||
Object.keys(obj).forEach(function(name){
|
||||
merge(ret, name, obj[name]);
|
||||
});
|
||||
return ret.base;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the given str.
|
||||
*/
|
||||
|
||||
function parseString(str){
|
||||
return String(str)
|
||||
.split('&')
|
||||
.reduce(function(ret, pair){
|
||||
var eql = pair.indexOf('=')
|
||||
, brace = lastBraceInKey(pair)
|
||||
, key = pair.substr(0, brace || eql)
|
||||
, val = pair.substr(brace || eql, pair.length)
|
||||
, val = val.substr(val.indexOf('=') + 1, val.length);
|
||||
|
||||
// ?foo
|
||||
if ('' == key) key = pair, val = '';
|
||||
|
||||
return merge(ret, decode(key), decode(val));
|
||||
}, { base: {} }).base;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the given query `str` or `obj`, returning an object.
|
||||
*
|
||||
* @param {String} str | {Object} obj
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.parse = function(str){
|
||||
if (null == str || '' == str) return {};
|
||||
return 'object' == typeof str
|
||||
? parseObject(str)
|
||||
: parseString(str);
|
||||
};
|
||||
|
||||
/**
|
||||
* Turn the given `obj` into a query string
|
||||
*
|
||||
* @param {Object} obj
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var stringify = exports.stringify = function(obj, prefix) {
|
||||
if (Array.isArray(obj)) {
|
||||
return stringifyArray(obj, prefix);
|
||||
} else if ('[object Object]' == toString.call(obj)) {
|
||||
return stringifyObject(obj, prefix);
|
||||
} else if ('string' == typeof obj) {
|
||||
return stringifyString(obj, prefix);
|
||||
} else {
|
||||
return prefix + '=' + encodeURIComponent(String(obj));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Stringify the given `str`.
|
||||
*
|
||||
* @param {String} str
|
||||
* @param {String} prefix
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function stringifyString(str, prefix) {
|
||||
if (!prefix) throw new TypeError('stringify expects an object');
|
||||
return prefix + '=' + encodeURIComponent(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stringify the given `arr`.
|
||||
*
|
||||
* @param {Array} arr
|
||||
* @param {String} prefix
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function stringifyArray(arr, prefix) {
|
||||
var ret = [];
|
||||
if (!prefix) throw new TypeError('stringify expects an object');
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
ret.push(stringify(arr[i], prefix + '[' + i + ']'));
|
||||
}
|
||||
return ret.join('&');
|
||||
}
|
||||
|
||||
/**
|
||||
* Stringify the given `obj`.
|
||||
*
|
||||
* @param {Object} obj
|
||||
* @param {String} prefix
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function stringifyObject(obj, prefix) {
|
||||
var ret = []
|
||||
, keys = Object.keys(obj)
|
||||
, key;
|
||||
|
||||
for (var i = 0, len = keys.length; i < len; ++i) {
|
||||
key = keys[i];
|
||||
ret.push(stringify(obj[key], prefix
|
||||
? prefix + '[' + encodeURIComponent(key) + ']'
|
||||
: encodeURIComponent(key)));
|
||||
}
|
||||
|
||||
return ret.join('&');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set `obj`'s `key` to `val` respecting
|
||||
* the weird and wonderful syntax of a qs,
|
||||
* where "foo=bar&foo=baz" becomes an array.
|
||||
*
|
||||
* @param {Object} obj
|
||||
* @param {String} key
|
||||
* @param {String} val
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function set(obj, key, val) {
|
||||
var v = obj[key];
|
||||
if (undefined === v) {
|
||||
obj[key] = val;
|
||||
} else if (Array.isArray(v)) {
|
||||
v.push(val);
|
||||
} else {
|
||||
obj[key] = [v, val];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate last brace in `str` within the key.
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {Number}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function lastBraceInKey(str) {
|
||||
var len = str.length
|
||||
, brace
|
||||
, c;
|
||||
for (var i = 0; i < len; ++i) {
|
||||
c = str[i];
|
||||
if (']' == c) brace = false;
|
||||
if ('[' == c) brace = true;
|
||||
if ('=' == c && !brace) return i;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode `str`.
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function decode(str) {
|
||||
try {
|
||||
return decodeURIComponent(str.replace(/\+/g, ' '));
|
||||
} catch (err) {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
39
node_modules/qs/package.json
generated
vendored
Normal file
39
node_modules/qs/package.json
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "qs",
|
||||
"description": "querystring parser",
|
||||
"version": "0.5.3",
|
||||
"keywords": [
|
||||
"query string",
|
||||
"parser",
|
||||
"component"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/visionmedia/node-querystring.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "*",
|
||||
"expect.js": "*"
|
||||
},
|
||||
"component": {
|
||||
"scripts": {
|
||||
"querystring": "querystring.js"
|
||||
}
|
||||
},
|
||||
"author": {
|
||||
"name": "TJ Holowaychuk",
|
||||
"email": "tj@vision-media.ca",
|
||||
"url": "http://tjholowaychuk.com"
|
||||
},
|
||||
"main": "index",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"readme": "# node-querystring\n\n query string parser for node and the browser supporting nesting, as it was removed from `0.3.x`, so this library provides the previous and commonly desired behaviour (and twice as fast). Used by [express](http://expressjs.com), [connect](http://senchalabs.github.com/connect) and others.\n\n## Installation\n\n $ npm install qs\n\n## Examples\n\n```js\nvar qs = require('qs');\n\nqs.parse('user[name][first]=Tobi&user[email]=tobi@learnboost.com');\n// => { user: { name: { first: 'Tobi' }, email: 'tobi@learnboost.com' } }\n\nqs.stringify({ user: { name: 'Tobi', email: 'tobi@learnboost.com' }})\n// => user[name]=Tobi&user[email]=tobi%40learnboost.com\n```\n\n## Testing\n\nInstall dev dependencies:\n\n $ npm install -d\n\nand execute:\n\n $ make test\n\nbrowser:\n\n $ open test/browser/index.html\n\n## License \n\n(The MIT License)\n\nCopyright (c) 2010 TJ Holowaychuk <tj@vision-media.ca>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
|
||||
"readmeFilename": "Readme.md",
|
||||
"_id": "qs@0.5.3",
|
||||
"dist": {
|
||||
"shasum": "40699a6db18d60119127d6ec666b855c61c3bb5f"
|
||||
},
|
||||
"_from": "qs"
|
||||
}
|
||||
1202
node_modules/qs/test/browser/expect.js
generated
vendored
Normal file
1202
node_modules/qs/test/browser/expect.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
18
node_modules/qs/test/browser/index.html
generated
vendored
Normal file
18
node_modules/qs/test/browser/index.html
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Mocha</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<link rel="stylesheet" href="mocha.css" />
|
||||
<script src="jquery.js" type="text/javascript"></script>
|
||||
<script src="expect.js"></script>
|
||||
<script src="mocha.js"></script>
|
||||
<script>mocha.setup('bdd')</script>
|
||||
<script src="qs.js"></script>
|
||||
<script src="../parse.js"></script>
|
||||
<script src="../stringify.js"></script>
|
||||
<script>onload = mocha.run;</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
</body>
|
||||
</html>
|
||||
8981
node_modules/qs/test/browser/jquery.js
generated
vendored
Normal file
8981
node_modules/qs/test/browser/jquery.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
163
node_modules/qs/test/browser/mocha.css
generated
vendored
Normal file
163
node_modules/qs/test/browser/mocha.css
generated
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
|
||||
body {
|
||||
font: 20px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
padding: 60px 50px;
|
||||
}
|
||||
|
||||
#mocha h1, h2 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#mocha h1 {
|
||||
margin-top: 15px;
|
||||
font-size: 1em;
|
||||
font-weight: 200;
|
||||
}
|
||||
|
||||
#mocha .suite .suite h1 {
|
||||
margin-top: 0;
|
||||
font-size: .8em;
|
||||
}
|
||||
|
||||
#mocha h2 {
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#mocha .suite {
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
#mocha .test {
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
#mocha .test:hover h2::after {
|
||||
position: relative;
|
||||
top: 0;
|
||||
right: -10px;
|
||||
content: '(view source)';
|
||||
font-size: 12px;
|
||||
font-family: arial;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
#mocha .test.pending:hover h2::after {
|
||||
content: '(pending)';
|
||||
font-family: arial;
|
||||
}
|
||||
|
||||
#mocha .test.pass.medium .duration {
|
||||
background: #C09853;
|
||||
}
|
||||
|
||||
#mocha .test.pass.slow .duration {
|
||||
background: #B94A48;
|
||||
}
|
||||
|
||||
#mocha .test.pass::before {
|
||||
content: '✓';
|
||||
font-size: 12px;
|
||||
display: block;
|
||||
float: left;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
#mocha .test.pass .duration {
|
||||
font-size: 9px;
|
||||
margin-left: 5px;
|
||||
padding: 2px 5px;
|
||||
color: white;
|
||||
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.2);
|
||||
-moz-box-shadow: inset 0 1px 1px rgba(0,0,0,.2);
|
||||
box-shadow: inset 0 1px 1px rgba(0,0,0,.2);
|
||||
-webkit-border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
-ms-border-radius: 5px;
|
||||
-o-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
#mocha .test.pass.fast .duration {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#mocha .test.pending {
|
||||
color: #0b97c4;
|
||||
}
|
||||
|
||||
#mocha .test.pending::before {
|
||||
content: '◦';
|
||||
color: #0b97c4;
|
||||
}
|
||||
|
||||
#mocha .test.fail {
|
||||
color: #c00;
|
||||
}
|
||||
|
||||
#mocha .test.fail pre {
|
||||
color: black;
|
||||
}
|
||||
|
||||
#mocha .test.fail::before {
|
||||
content: '✖';
|
||||
font-size: 12px;
|
||||
display: block;
|
||||
float: left;
|
||||
margin-right: 5px;
|
||||
color: #c00;
|
||||
}
|
||||
|
||||
#mocha .test pre.error {
|
||||
color: #c00;
|
||||
}
|
||||
|
||||
#mocha .test pre {
|
||||
display: inline-block;
|
||||
font: 12px/1.5 monaco, monospace;
|
||||
margin: 5px;
|
||||
padding: 15px;
|
||||
border: 1px solid #eee;
|
||||
border-bottom-color: #ddd;
|
||||
-webkit-border-radius: 3px;
|
||||
-webkit-box-shadow: 0 1px 3px #eee;
|
||||
}
|
||||
|
||||
#error {
|
||||
color: #c00;
|
||||
font-size: 1.5 em;
|
||||
font-weight: 100;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
#stats {
|
||||
position: fixed;
|
||||
top: 15px;
|
||||
right: 10px;
|
||||
font-size: 12px;
|
||||
margin: 0;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
#stats .progress {
|
||||
float: right;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
#stats em {
|
||||
color: black;
|
||||
}
|
||||
|
||||
#stats li {
|
||||
display: inline-block;
|
||||
margin: 0 5px;
|
||||
list-style: none;
|
||||
padding-top: 11px;
|
||||
}
|
||||
|
||||
code .comment { color: #ddd }
|
||||
code .init { color: #2F6FAD }
|
||||
code .string { color: #5890AD }
|
||||
code .keyword { color: #8A6343 }
|
||||
code .number { color: #2F6FAD }
|
||||
4201
node_modules/qs/test/browser/mocha.js
generated
vendored
Normal file
4201
node_modules/qs/test/browser/mocha.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
0
node_modules/qs/test/browser/qs.css
generated
vendored
Normal file
0
node_modules/qs/test/browser/qs.css
generated
vendored
Normal file
351
node_modules/qs/test/browser/qs.js
generated
vendored
Normal file
351
node_modules/qs/test/browser/qs.js
generated
vendored
Normal file
@@ -0,0 +1,351 @@
|
||||
|
||||
/**
|
||||
* Require the given path.
|
||||
*
|
||||
* @param {String} path
|
||||
* @return {Object} exports
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function require(p, parent){
|
||||
var path = require.resolve(p)
|
||||
, mod = require.modules[path];
|
||||
if (!mod) throw new Error('failed to require "' + p + '" in ' + parent);
|
||||
if (!mod.exports) {
|
||||
mod.exports = {};
|
||||
mod.client = true;
|
||||
mod.call(mod.exports, mod, mod.exports, require.relative(path));
|
||||
}
|
||||
return mod.exports;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registered modules.
|
||||
*/
|
||||
|
||||
require.modules = {};
|
||||
|
||||
/**
|
||||
* Resolve `path`.
|
||||
*
|
||||
* @param {String} path
|
||||
* @return {Object} module
|
||||
* @api public
|
||||
*/
|
||||
|
||||
require.resolve = function(path){
|
||||
var orig = path
|
||||
, reg = path + '.js'
|
||||
, index = path + '/index.js';
|
||||
return require.modules[reg] && reg
|
||||
|| require.modules[index] && index
|
||||
|| orig;
|
||||
};
|
||||
|
||||
/**
|
||||
* Register module at `path` with callback `fn`.
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {Function} fn
|
||||
* @api public
|
||||
*/
|
||||
|
||||
require.register = function(path, fn){
|
||||
require.modules[path] = fn;
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines and executes anonymous module immediately, while preserving relative
|
||||
* paths.
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {Function} require ref
|
||||
* @api public
|
||||
*/
|
||||
|
||||
require.exec = function (path, fn) {
|
||||
fn.call(window, require.relative(path));
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a require function relative to the `parent` path.
|
||||
*
|
||||
* @param {String} parent
|
||||
* @return {Function}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
require.relative = function(parent) {
|
||||
return function(p){
|
||||
if ('.' != p[0]) return require(p);
|
||||
|
||||
var path = parent.split('/')
|
||||
, segs = p.split('/');
|
||||
path.pop();
|
||||
|
||||
for (var i = 0; i < segs.length; i++) {
|
||||
var seg = segs[i];
|
||||
if ('..' == seg) path.pop();
|
||||
else if ('.' != seg) path.push(seg);
|
||||
}
|
||||
|
||||
return require(path.join('/'), parent);
|
||||
};
|
||||
};
|
||||
// component qs: querystring
|
||||
require.register("querystring", function(module, exports, require){
|
||||
;(function(){
|
||||
|
||||
/**
|
||||
* Object#toString() ref for stringify().
|
||||
*/
|
||||
|
||||
var toString = Object.prototype.toString;
|
||||
|
||||
/**
|
||||
* Cache non-integer test regexp.
|
||||
*/
|
||||
|
||||
var isint = /^[0-9]+$/;
|
||||
|
||||
function promote(parent, key) {
|
||||
if (parent[key].length == 0) return parent[key] = {};
|
||||
var t = {};
|
||||
for (var i in parent[key]) t[i] = parent[key][i];
|
||||
parent[key] = t;
|
||||
return t;
|
||||
}
|
||||
|
||||
function parse(parts, parent, key, val) {
|
||||
var part = parts.shift();
|
||||
// end
|
||||
if (!part) {
|
||||
if (Array.isArray(parent[key])) {
|
||||
parent[key].push(val);
|
||||
} else if ('object' == typeof parent[key]) {
|
||||
parent[key] = val;
|
||||
} else if ('undefined' == typeof parent[key]) {
|
||||
parent[key] = val;
|
||||
} else {
|
||||
parent[key] = [parent[key], val];
|
||||
}
|
||||
// array
|
||||
} else {
|
||||
var obj = parent[key] = parent[key] || [];
|
||||
if (']' == part) {
|
||||
if (Array.isArray(obj)) {
|
||||
if ('' != val) obj.push(val);
|
||||
} else if ('object' == typeof obj) {
|
||||
obj[Object.keys(obj).length] = val;
|
||||
} else {
|
||||
obj = parent[key] = [parent[key], val];
|
||||
}
|
||||
// prop
|
||||
} else if (~part.indexOf(']')) {
|
||||
part = part.substr(0, part.length - 1);
|
||||
if (!isint.test(part) && Array.isArray(obj)) obj = promote(parent, key);
|
||||
parse(parts, obj, part, val);
|
||||
// key
|
||||
} else {
|
||||
if (!isint.test(part) && Array.isArray(obj)) obj = promote(parent, key);
|
||||
parse(parts, obj, part, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge parent key/val pair.
|
||||
*/
|
||||
|
||||
function merge(parent, key, val){
|
||||
if (~key.indexOf(']')) {
|
||||
var parts = key.split('[')
|
||||
, len = parts.length
|
||||
, last = len - 1;
|
||||
parse(parts, parent, 'base', val);
|
||||
// optimize
|
||||
} else {
|
||||
if (!isint.test(key) && Array.isArray(parent.base)) {
|
||||
var t = {};
|
||||
for (var k in parent.base) t[k] = parent.base[k];
|
||||
parent.base = t;
|
||||
}
|
||||
set(parent.base, key, val);
|
||||
}
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the given obj.
|
||||
*/
|
||||
|
||||
function parseObject(obj){
|
||||
var ret = { base: {} };
|
||||
Object.keys(obj).forEach(function(name){
|
||||
merge(ret, name, obj[name]);
|
||||
});
|
||||
return ret.base;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the given str.
|
||||
*/
|
||||
|
||||
function parseString(str){
|
||||
return String(str)
|
||||
.split('&')
|
||||
.reduce(function(ret, pair){
|
||||
try{
|
||||
pair = decodeURIComponent(pair.replace(/\+/g, ' '));
|
||||
} catch(e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
var eql = pair.indexOf('=')
|
||||
, brace = lastBraceInKey(pair)
|
||||
, key = pair.substr(0, brace || eql)
|
||||
, val = pair.substr(brace || eql, pair.length)
|
||||
, val = val.substr(val.indexOf('=') + 1, val.length);
|
||||
|
||||
// ?foo
|
||||
if ('' == key) key = pair, val = '';
|
||||
|
||||
return merge(ret, key, val);
|
||||
}, { base: {} }).base;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the given query `str` or `obj`, returning an object.
|
||||
*
|
||||
* @param {String} str | {Object} obj
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.parse = function(str){
|
||||
if (null == str || '' == str) return {};
|
||||
return 'object' == typeof str
|
||||
? parseObject(str)
|
||||
: parseString(str);
|
||||
};
|
||||
|
||||
/**
|
||||
* Turn the given `obj` into a query string
|
||||
*
|
||||
* @param {Object} obj
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var stringify = exports.stringify = function(obj, prefix) {
|
||||
if (Array.isArray(obj)) {
|
||||
return stringifyArray(obj, prefix);
|
||||
} else if ('[object Object]' == toString.call(obj)) {
|
||||
return stringifyObject(obj, prefix);
|
||||
} else if ('string' == typeof obj) {
|
||||
return stringifyString(obj, prefix);
|
||||
} else {
|
||||
return prefix + '=' + obj;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Stringify the given `str`.
|
||||
*
|
||||
* @param {String} str
|
||||
* @param {String} prefix
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function stringifyString(str, prefix) {
|
||||
if (!prefix) throw new TypeError('stringify expects an object');
|
||||
return prefix + '=' + encodeURIComponent(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stringify the given `arr`.
|
||||
*
|
||||
* @param {Array} arr
|
||||
* @param {String} prefix
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function stringifyArray(arr, prefix) {
|
||||
var ret = [];
|
||||
if (!prefix) throw new TypeError('stringify expects an object');
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
ret.push(stringify(arr[i], prefix + '['+i+']'));
|
||||
}
|
||||
return ret.join('&');
|
||||
}
|
||||
|
||||
/**
|
||||
* Stringify the given `obj`.
|
||||
*
|
||||
* @param {Object} obj
|
||||
* @param {String} prefix
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function stringifyObject(obj, prefix) {
|
||||
var ret = []
|
||||
, keys = Object.keys(obj)
|
||||
, key;
|
||||
|
||||
for (var i = 0, len = keys.length; i < len; ++i) {
|
||||
key = keys[i];
|
||||
ret.push(stringify(obj[key], prefix
|
||||
? prefix + '[' + encodeURIComponent(key) + ']'
|
||||
: encodeURIComponent(key)));
|
||||
}
|
||||
|
||||
return ret.join('&');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set `obj`'s `key` to `val` respecting
|
||||
* the weird and wonderful syntax of a qs,
|
||||
* where "foo=bar&foo=baz" becomes an array.
|
||||
*
|
||||
* @param {Object} obj
|
||||
* @param {String} key
|
||||
* @param {String} val
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function set(obj, key, val) {
|
||||
var v = obj[key];
|
||||
if (undefined === v) {
|
||||
obj[key] = val;
|
||||
} else if (Array.isArray(v)) {
|
||||
v.push(val);
|
||||
} else {
|
||||
obj[key] = [v, val];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate last brace in `str` within the key.
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {Number}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function lastBraceInKey(str) {
|
||||
var len = str.length
|
||||
, brace
|
||||
, c;
|
||||
for (var i = 0; i < len; ++i) {
|
||||
c = str[i];
|
||||
if (']' == c) brace = false;
|
||||
if ('[' == c) brace = true;
|
||||
if ('=' == c && !brace) return i;
|
||||
}
|
||||
}
|
||||
})();
|
||||
});
|
||||
147
node_modules/qs/test/parse.js
generated
vendored
Normal file
147
node_modules/qs/test/parse.js
generated
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
|
||||
if (require.register) {
|
||||
var qs = require('querystring');
|
||||
} else {
|
||||
var qs = require('../')
|
||||
, expect = require('expect.js');
|
||||
}
|
||||
|
||||
describe('qs.parse()', function(){
|
||||
it('should support the basics', function(){
|
||||
expect(qs.parse('0=foo')).to.eql({ '0': 'foo' });
|
||||
|
||||
expect(qs.parse('foo=c++'))
|
||||
.to.eql({ foo: 'c ' });
|
||||
|
||||
expect(qs.parse('a[>=]=23'))
|
||||
.to.eql({ a: { '>=': '23' }});
|
||||
|
||||
expect(qs.parse('a[<=>]==23'))
|
||||
.to.eql({ a: { '<=>': '=23' }});
|
||||
|
||||
expect(qs.parse('a[==]=23'))
|
||||
.to.eql({ a: { '==': '23' }});
|
||||
|
||||
expect(qs.parse('foo'))
|
||||
.to.eql({ foo: '' });
|
||||
|
||||
expect(qs.parse('foo=bar'))
|
||||
.to.eql({ foo: 'bar' });
|
||||
|
||||
expect(qs.parse(' foo = bar = baz '))
|
||||
.to.eql({ ' foo ': ' bar = baz ' });
|
||||
|
||||
expect(qs.parse('foo=bar=baz'))
|
||||
.to.eql({ foo: 'bar=baz' });
|
||||
|
||||
expect(qs.parse('foo=bar&bar=baz'))
|
||||
.to.eql({ foo: 'bar', bar: 'baz' });
|
||||
|
||||
expect(qs.parse('foo=bar&baz'))
|
||||
.to.eql({ foo: 'bar', baz: '' });
|
||||
|
||||
expect(qs.parse('cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World'))
|
||||
.to.eql({
|
||||
cht: 'p3'
|
||||
, chd: 't:60,40'
|
||||
, chs: '250x100'
|
||||
, chl: 'Hello|World'
|
||||
});
|
||||
})
|
||||
|
||||
it('should support encoded = signs', function(){
|
||||
expect(qs.parse('he%3Dllo=th%3Dere'))
|
||||
.to.eql({ 'he=llo': 'th=ere' });
|
||||
})
|
||||
|
||||
it('should support nesting', function(){
|
||||
expect(qs.parse('ops[>=]=25'))
|
||||
.to.eql({ ops: { '>=': '25' }});
|
||||
|
||||
expect(qs.parse('user[name]=tj'))
|
||||
.to.eql({ user: { name: 'tj' }});
|
||||
|
||||
expect(qs.parse('user[name][first]=tj&user[name][last]=holowaychuk'))
|
||||
.to.eql({ user: { name: { first: 'tj', last: 'holowaychuk' }}});
|
||||
})
|
||||
|
||||
it('should support array notation', function(){
|
||||
expect(qs.parse('images[]'))
|
||||
.to.eql({ images: [] });
|
||||
|
||||
expect(qs.parse('user[]=tj'))
|
||||
.to.eql({ user: ['tj'] });
|
||||
|
||||
expect(qs.parse('user[]=tj&user[]=tobi&user[]=jane'))
|
||||
.to.eql({ user: ['tj', 'tobi', 'jane'] });
|
||||
|
||||
expect(qs.parse('user[names][]=tj&user[names][]=tyler'))
|
||||
.to.eql({ user: { names: ['tj', 'tyler'] }});
|
||||
|
||||
expect(qs.parse('user[names][]=tj&user[names][]=tyler&user[email]=tj@vision-media.ca'))
|
||||
.to.eql({ user: { names: ['tj', 'tyler'], email: 'tj@vision-media.ca' }});
|
||||
|
||||
expect(qs.parse('items=a&items=b'))
|
||||
.to.eql({ items: ['a', 'b'] });
|
||||
|
||||
expect(qs.parse('user[names]=tj&user[names]=holowaychuk&user[names]=TJ'))
|
||||
.to.eql({ user: { names: ['tj', 'holowaychuk', 'TJ'] }});
|
||||
|
||||
expect(qs.parse('user[name][first]=tj&user[name][first]=TJ'))
|
||||
.to.eql({ user: { name: { first: ['tj', 'TJ'] }}});
|
||||
|
||||
var o = qs.parse('existing[fcbaebfecc][name][last]=tj')
|
||||
expect(o).to.eql({ existing: { 'fcbaebfecc': { name: { last: 'tj' }}}})
|
||||
expect(Array.isArray(o.existing)).to.equal(false);
|
||||
})
|
||||
|
||||
it('should support arrays with indexes', function(){
|
||||
expect(qs.parse('foo[0]=bar&foo[1]=baz')).to.eql({ foo: ['bar', 'baz'] });
|
||||
expect(qs.parse('foo[1]=bar&foo[0]=baz')).to.eql({ foo: ['baz', 'bar'] });
|
||||
expect(qs.parse('foo[base64]=RAWR')).to.eql({ foo: { base64: 'RAWR' }});
|
||||
expect(qs.parse('foo[64base]=RAWR')).to.eql({ foo: { '64base': 'RAWR' }});
|
||||
})
|
||||
|
||||
it('should expand to an array when dupliate keys are present', function(){
|
||||
expect(qs.parse('items=bar&items=baz&items=raz'))
|
||||
.to.eql({ items: ['bar', 'baz', 'raz'] });
|
||||
})
|
||||
|
||||
it('should support right-hand side brackets', function(){
|
||||
expect(qs.parse('pets=["tobi"]'))
|
||||
.to.eql({ pets: '["tobi"]' });
|
||||
|
||||
expect(qs.parse('operators=[">=", "<="]'))
|
||||
.to.eql({ operators: '[">=", "<="]' });
|
||||
|
||||
expect(qs.parse('op[>=]=[1,2,3]'))
|
||||
.to.eql({ op: { '>=': '[1,2,3]' }});
|
||||
|
||||
expect(qs.parse('op[>=]=[1,2,3]&op[=]=[[[[1]]]]'))
|
||||
.to.eql({ op: { '>=': '[1,2,3]', '=': '[[[[1]]]]' }});
|
||||
})
|
||||
|
||||
it('should support empty values', function(){
|
||||
expect(qs.parse('')).to.eql({});
|
||||
expect(qs.parse(undefined)).to.eql({});
|
||||
expect(qs.parse(null)).to.eql({});
|
||||
})
|
||||
|
||||
it('should transform arrays to objects', function(){
|
||||
expect(qs.parse('foo[0]=bar&foo[bad]=baz')).to.eql({ foo: { 0: "bar", bad: "baz" }});
|
||||
expect(qs.parse('foo[bad]=baz&foo[0]=bar')).to.eql({ foo: { 0: "bar", bad: "baz" }});
|
||||
})
|
||||
|
||||
it('should support malformed uri chars', function(){
|
||||
expect(qs.parse('{%:%}')).to.eql({ '{%:%}': '' });
|
||||
expect(qs.parse('foo=%:%}')).to.eql({ 'foo': '%:%}' });
|
||||
})
|
||||
|
||||
it('should support semi-parsed strings', function(){
|
||||
expect(qs.parse({ 'user[name]': 'tobi' }))
|
||||
.to.eql({ user: { name: 'tobi' }});
|
||||
|
||||
expect(qs.parse({ 'user[name]': 'tobi', 'user[email][main]': 'tobi@lb.com' }))
|
||||
.to.eql({ user: { name: 'tobi', email: { main: 'tobi@lb.com' } }});
|
||||
})
|
||||
})
|
||||
79
node_modules/qs/test/stringify.js
generated
vendored
Normal file
79
node_modules/qs/test/stringify.js
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
|
||||
if (require.register) {
|
||||
var qs = require('querystring');
|
||||
} else {
|
||||
var qs = require('../')
|
||||
, expect = require('expect.js');
|
||||
}
|
||||
|
||||
var date = new Date(0);
|
||||
|
||||
var str_identities = {
|
||||
'basics': [
|
||||
{ str: 'foo=bar', obj: {'foo' : 'bar'}},
|
||||
{ str: 'foo=%22bar%22', obj: {'foo' : '\"bar\"'}},
|
||||
{ str: 'foo=', obj: {'foo': ''}},
|
||||
{ str: 'foo=1&bar=2', obj: {'foo' : '1', 'bar' : '2'}},
|
||||
{ str: 'my%20weird%20field=q1!2%22\'w%245%267%2Fz8)%3F', obj: {'my weird field': "q1!2\"'w$5&7/z8)?"}},
|
||||
{ str: 'foo%3Dbaz=bar', obj: {'foo=baz': 'bar'}},
|
||||
{ str: 'foo=bar&bar=baz', obj: {foo: 'bar', bar: 'baz'}}
|
||||
],
|
||||
'escaping': [
|
||||
{ str: 'foo=foo%20bar', obj: {foo: 'foo bar'}},
|
||||
{ str: 'cht=p3&chd=t%3A60%2C40&chs=250x100&chl=Hello%7CWorld', obj: {
|
||||
cht: 'p3'
|
||||
, chd: 't:60,40'
|
||||
, chs: '250x100'
|
||||
, chl: 'Hello|World'
|
||||
}}
|
||||
],
|
||||
'nested': [
|
||||
{ str: 'foo[0]=bar&foo[1]=quux', obj: {'foo' : ['bar', 'quux']}},
|
||||
{ str: 'foo[0]=bar', obj: {foo: ['bar']}},
|
||||
{ str: 'foo[0]=1&foo[1]=2', obj: {'foo' : ['1', '2']}},
|
||||
{ str: 'foo=bar&baz[0]=1&baz[1]=2&baz[2]=3', obj: {'foo' : 'bar', 'baz' : ['1', '2', '3']}},
|
||||
{ str: 'foo[0]=bar&baz[0]=1&baz[1]=2&baz[2]=3', obj: {'foo' : ['bar'], 'baz' : ['1', '2', '3']}},
|
||||
{ str: 'x[y][z]=1', obj: {'x' : {'y' : {'z' : '1'}}}},
|
||||
{ str: 'x[y][z][0]=1', obj: {'x' : {'y' : {'z' : ['1']}}}},
|
||||
{ str: 'x[y][z]=2', obj: {'x' : {'y' : {'z' : '2'}}}},
|
||||
{ str: 'x[y][z][0]=1&x[y][z][1]=2', obj: {'x' : {'y' : {'z' : ['1', '2']}}}},
|
||||
{ str: 'x[y][0][z]=1', obj: {'x' : {'y' : [{'z' : '1'}]}}},
|
||||
{ str: 'x[y][0][z][0]=1', obj: {'x' : {'y' : [{'z' : ['1']}]}}},
|
||||
{ str: 'x[y][0][z]=1&x[y][0][w]=2', obj: {'x' : {'y' : [{'z' : '1', 'w' : '2'}]}}},
|
||||
{ str: 'x[y][0][v][w]=1', obj: {'x' : {'y' : [{'v' : {'w' : '1'}}]}}},
|
||||
{ str: 'x[y][0][z]=1&x[y][0][v][w]=2', obj: {'x' : {'y' : [{'z' : '1', 'v' : {'w' : '2'}}]}}},
|
||||
{ str: 'x[y][0][z]=1&x[y][1][z]=2', obj: {'x' : {'y' : [{'z' : '1'}, {'z' : '2'}]}}},
|
||||
{ str: 'x[y][0][z]=1&x[y][0][w]=a&x[y][1][z]=2&x[y][1][w]=3', obj: {'x' : {'y' : [{'z' : '1', 'w' : 'a'}, {'z' : '2', 'w' : '3'}]}}},
|
||||
{ str: 'user[name][first]=tj&user[name][last]=holowaychuk', obj: { user: { name: { first: 'tj', last: 'holowaychuk' }}}}
|
||||
],
|
||||
'errors': [
|
||||
{ obj: 'foo=bar', message: 'stringify expects an object' },
|
||||
{ obj: ['foo', 'bar'], message: 'stringify expects an object' }
|
||||
],
|
||||
'numbers': [
|
||||
{ str: 'limit[0]=1&limit[1]=2&limit[2]=3', obj: { limit: [1, 2, '3'] }},
|
||||
{ str: 'limit=1', obj: { limit: 1 }}
|
||||
],
|
||||
'others': [
|
||||
{ str: 'at=' + encodeURIComponent(date), obj: { at: date } }
|
||||
]
|
||||
};
|
||||
|
||||
function test(type) {
|
||||
return function(){
|
||||
var str, obj;
|
||||
for (var i = 0; i < str_identities[type].length; i++) {
|
||||
str = str_identities[type][i].str;
|
||||
obj = str_identities[type][i].obj;
|
||||
expect(qs.stringify(obj)).to.eql(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
describe('qs.stringify()', function(){
|
||||
it('should support the basics', test('basics'))
|
||||
it('should support escapes', test('escaping'))
|
||||
it('should support nesting', test('nested'))
|
||||
it('should support numbers', test('numbers'))
|
||||
it('should support others', test('others'))
|
||||
})
|
||||
Reference in New Issue
Block a user