complete redesign: use nodejs on server instead of php - documentation to be updated

This commit is contained in:
Marc Wäckerlin
2016-01-10 23:17:30 +00:00
parent 1c3765955b
commit a56d3118de
1376 changed files with 183732 additions and 1253 deletions

View 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

View File

@@ -0,0 +1 @@
node_modules

View File

@@ -0,0 +1,4 @@
language: node_js
node_js:
- 0.6
- 0.4

73
nodejs/node_modules/express/node_modules/qs/History.md generated vendored Normal file
View File

@@ -0,0 +1,73 @@
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

5
nodejs/node_modules/express/node_modules/qs/Makefile generated vendored Normal file
View File

@@ -0,0 +1,5 @@
test:
@./node_modules/.bin/mocha
.PHONY: test

54
nodejs/node_modules/express/node_modules/qs/Readme.md generated vendored Normal file
View File

@@ -0,0 +1,54 @@
# node-querystring
query string parser for node 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
## 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.

View 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);

View 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);

2
nodejs/node_modules/express/node_modules/qs/index.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
module.exports = require('./lib/querystring');

View File

@@ -0,0 +1,264 @@
/*!
* querystring
* Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
/**
* Library version.
*/
exports.version = '0.4.2';
/**
* 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 + '[]'));
}
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;
}
}

View File

@@ -0,0 +1,33 @@
{
"name": "qs",
"description": "querystring parser",
"version": "0.4.2",
"repository": {
"type": "git",
"url": "git://github.com/visionmedia/node-querystring.git"
},
"devDependencies": {
"mocha": "*",
"should": "*"
},
"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 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\n## License \n\n(The MIT License)\n\nCopyright (c) 2010 TJ Holowaychuk &lt;tj@vision-media.ca&gt;\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",
"bugs": {
"url": "https://github.com/visionmedia/node-querystring/issues"
},
"_id": "qs@0.4.2",
"dist": {
"shasum": "d4f9a94991c3bbee4d1abec770b014ecae41cbb3"
},
"_from": "qs@0.4.x",
"_resolved": "https://registry.npmjs.org/qs/-/qs-0.4.2.tgz"
}

View File

@@ -0,0 +1,2 @@
--require should
--ui exports

View File

@@ -0,0 +1,167 @@
/**
* Module dependencies.
*/
var qs = require('../');
module.exports = {
'test basics': function(){
qs.parse('0=foo').should.eql({ '0': 'foo' });
qs.parse('foo=c++')
.should.eql({ foo: 'c ' });
qs.parse('a[>=]=23')
.should.eql({ a: { '>=': '23' }});
qs.parse('a[<=>]==23')
.should.eql({ a: { '<=>': '=23' }});
qs.parse('a[==]=23')
.should.eql({ a: { '==': '23' }});
qs.parse('foo')
.should.eql({ foo: '' });
qs.parse('foo=bar')
.should.eql({ foo: 'bar' });
qs.parse('foo%3Dbar=baz')
.should.eql({ foo: 'bar=baz' });
qs.parse(' foo = bar = baz ')
.should.eql({ ' foo ': ' bar = baz ' });
qs.parse('foo=bar=baz')
.should.eql({ foo: 'bar=baz' });
qs.parse('foo=bar&bar=baz')
.should.eql({ foo: 'bar', bar: 'baz' });
qs.parse('foo=bar&baz')
.should.eql({ foo: 'bar', baz: '' });
qs.parse('cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World')
.should.eql({
cht: 'p3'
, chd: 't:60,40'
, chs: '250x100'
, chl: 'Hello|World'
});
},
'test nesting': function(){
qs.parse('ops[>=]=25')
.should.eql({ ops: { '>=': '25' }});
qs.parse('user[name]=tj')
.should.eql({ user: { name: 'tj' }});
qs.parse('user[name][first]=tj&user[name][last]=holowaychuk')
.should.eql({ user: { name: { first: 'tj', last: 'holowaychuk' }}});
},
'test escaping': function(){
qs.parse('foo=foo%20bar')
.should.eql({ foo: 'foo bar' });
},
'test arrays': function(){
qs.parse('images[]')
.should.eql({ images: [] });
qs.parse('user[]=tj')
.should.eql({ user: ['tj'] });
qs.parse('user[]=tj&user[]=tobi&user[]=jane')
.should.eql({ user: ['tj', 'tobi', 'jane'] });
qs.parse('user[names][]=tj&user[names][]=tyler')
.should.eql({ user: { names: ['tj', 'tyler'] }});
qs.parse('user[names][]=tj&user[names][]=tyler&user[email]=tj@vision-media.ca')
.should.eql({ user: { names: ['tj', 'tyler'], email: 'tj@vision-media.ca' }});
qs.parse('items=a&items=b')
.should.eql({ items: ['a', 'b'] });
qs.parse('user[names]=tj&user[names]=holowaychuk&user[names]=TJ')
.should.eql({ user: { names: ['tj', 'holowaychuk', 'TJ'] }});
qs.parse('user[name][first]=tj&user[name][first]=TJ')
.should.eql({ user: { name: { first: ['tj', 'TJ'] }}});
var o = qs.parse('existing[fcbaebfecc][name][last]=tj')
o.should.eql({ existing: { 'fcbaebfecc': { name: { last: 'tj' }}}})
Array.isArray(o.existing).should.be.false;
},
'test right-hand brackets': function(){
qs.parse('pets=["tobi"]')
.should.eql({ pets: '["tobi"]' });
qs.parse('operators=[">=", "<="]')
.should.eql({ operators: '[">=", "<="]' });
qs.parse('op[>=]=[1,2,3]')
.should.eql({ op: { '>=': '[1,2,3]' }});
qs.parse('op[>=]=[1,2,3]&op[=]=[[[[1]]]]')
.should.eql({ op: { '>=': '[1,2,3]', '=': '[[[[1]]]]' }});
},
'test duplicates': function(){
qs.parse('items=bar&items=baz&items=raz')
.should.eql({ items: ['bar', 'baz', 'raz'] });
},
'test empty': function(){
qs.parse('').should.eql({});
qs.parse(undefined).should.eql({});
qs.parse(null).should.eql({});
},
'test arrays with indexes': function(){
qs.parse('foo[0]=bar&foo[1]=baz').should.eql({ foo: ['bar', 'baz'] });
qs.parse('foo[1]=bar&foo[0]=baz').should.eql({ foo: ['baz', 'bar'] });
qs.parse('foo[base64]=RAWR').should.eql({ foo: { base64: 'RAWR' }});
qs.parse('foo[64base]=RAWR').should.eql({ foo: { '64base': 'RAWR' }});
},
'test arrays becoming objects': function(){
qs.parse('foo[0]=bar&foo[bad]=baz').should.eql({ foo: { 0: "bar", bad: "baz" }});
qs.parse('foo[bad]=baz&foo[0]=bar').should.eql({ foo: { 0: "bar", bad: "baz" }});
},
'test bleed-through of Array native properties/methods': function(){
Array.prototype.protoProperty = true;
Array.prototype.protoFunction = function () {};
qs.parse('foo=bar').should.eql({ foo: 'bar' });
},
'test malformed uri': function(){
qs.parse('{%:%}').should.eql({ '{%:%}': '' });
qs.parse('foo=%:%}').should.eql({ 'foo': '%:%}' });
},
'test semi-parsed': function(){
qs.parse({ 'user[name]': 'tobi' })
.should.eql({ user: { name: 'tobi' }});
qs.parse({ 'user[name]': 'tobi', 'user[email][main]': 'tobi@lb.com' })
.should.eql({ user: { name: 'tobi', email: { main: 'tobi@lb.com' } }});
}
// 'test complex': function(){
// qs.parse('users[][name][first]=tj&users[foo]=bar')
// .should.eql({
// users: [ { name: 'tj' }, { name: 'tobi' }, { foo: 'bar' }]
// });
//
// qs.parse('users[][name][first]=tj&users[][name][first]=tobi')
// .should.eql({
// users: [ { name: 'tj' }, { name: 'tobi' }]
// });
// }
};

View File

@@ -0,0 +1,103 @@
/**
* Module dependencies.
*/
var qs = require('../')
, should = require('should')
, 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[]=bar&foo[]=quux', obj: {'foo' : ['bar', 'quux']}},
{ str: 'foo[]=bar', obj: {foo: ['bar']}},
{ str: 'foo[]=1&foo[]=2', obj: {'foo' : ['1', '2']}},
{ str: 'foo=bar&baz[]=1&baz[]=2&baz[]=3', obj: {'foo' : 'bar', 'baz' : ['1', '2', '3']}},
{ str: 'foo[]=bar&baz[]=1&baz[]=2&baz[]=3', obj: {'foo' : ['bar'], 'baz' : ['1', '2', '3']}},
{ str: 'x[y][z]=1', obj: {'x' : {'y' : {'z' : '1'}}}},
{ str: 'x[y][z][]=1', obj: {'x' : {'y' : {'z' : ['1']}}}},
{ str: 'x[y][z]=2', obj: {'x' : {'y' : {'z' : '2'}}}},
{ str: 'x[y][z][]=1&x[y][z][]=2', obj: {'x' : {'y' : {'z' : ['1', '2']}}}},
{ str: 'x[y][][z]=1', obj: {'x' : {'y' : [{'z' : '1'}]}}},
{ str: 'x[y][][z][]=1', obj: {'x' : {'y' : [{'z' : ['1']}]}}},
{ str: 'x[y][][z]=1&x[y][][w]=2', obj: {'x' : {'y' : [{'z' : '1', 'w' : '2'}]}}},
{ str: 'x[y][][v][w]=1', obj: {'x' : {'y' : [{'v' : {'w' : '1'}}]}}},
{ str: 'x[y][][z]=1&x[y][][v][w]=2', obj: {'x' : {'y' : [{'z' : '1', 'v' : {'w' : '2'}}]}}},
{ str: 'x[y][][z]=1&x[y][][z]=2', obj: {'x' : {'y' : [{'z' : '1'}, {'z' : '2'}]}}},
{ str: 'x[y][][z]=1&x[y][][w]=a&x[y][][z]=2&x[y][][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[]=1&limit[]=2&limit[]=3', obj: { limit: [1, 2, '3'] }},
{ str: 'limit=1', obj: { limit: 1 }}
]
};
// Assert error
function err(fn, msg){
var err;
try {
fn();
} catch (e) {
should.equal(e.message, msg);
return;
}
throw new Error('no exception thrown, expected "' + msg + '"');
}
function test(type) {
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;
qs.stringify(obj).should.eql(str);
}
}
module.exports = {
'test basics': function() {
test('basics');
},
'test escaping': function() {
test('escaping');
},
'test nested': function() {
test('nested');
},
'test numbers': function(){
test('numbers');
},
'test errors': function() {
var obj, message;
for (var i = 0; i < str_identities['errors'].length; i++) {
message = str_identities['errors'][i].message;
obj = str_identities['errors'][i].obj;
err(function(){ qs.stringify(obj) }, message);
}
}
};