mirror of
https://github.com/sstent/expressmongotest.git
synced 2026-01-26 17:12:33 +00:00
added article
This commit is contained in:
BIN
test/node_modules/querystring/.History.md.un~
generated
vendored
Normal file
BIN
test/node_modules/querystring/.History.md.un~
generated
vendored
Normal file
Binary file not shown.
BIN
test/node_modules/querystring/.package.json.un~
generated
vendored
Normal file
BIN
test/node_modules/querystring/.package.json.un~
generated
vendored
Normal file
Binary file not shown.
7
test/node_modules/querystring/History.md
generated
vendored
Normal file
7
test/node_modules/querystring/History.md
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# 0.0.3 / 2011-04-16 #
|
||||
- Support for AMD module loaders
|
||||
# 0.0.2 / 2011-04-16 #
|
||||
- Ported unit tests
|
||||
- Removed functionality that depended on Buffers
|
||||
# 0.0.1 / 2011-04-15 #
|
||||
- Initial release
|
||||
8
test/node_modules/querystring/Readme.md
generated
vendored
Normal file
8
test/node_modules/querystring/Readme.md
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# querystring #
|
||||
|
||||
Node's querystring module for all engines.
|
||||
|
||||
## Install ##
|
||||
|
||||
npm install querystring
|
||||
|
||||
40
test/node_modules/querystring/package.json
generated
vendored
Normal file
40
test/node_modules/querystring/package.json
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "querystring",
|
||||
"id": "querystring",
|
||||
"version": "0.1.0",
|
||||
"description": "Node's querystring module for all engines.",
|
||||
"keywords": [
|
||||
"commonjs",
|
||||
"query",
|
||||
"querystring"
|
||||
],
|
||||
"author": {
|
||||
"name": "Irakli Gozalishvili",
|
||||
"email": "rfobic@gmail.com"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/Gozala/querystring.git",
|
||||
"web": "https://github.com/Gozala/querystring"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "http://github.com/Gozala/querystring/issues/"
|
||||
},
|
||||
"devDependencies": {
|
||||
"test": ">=0.4.3"
|
||||
},
|
||||
"main": "./querystring.js",
|
||||
"engines": {
|
||||
"node": ">=0.4.x"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node tests/test-querystring.js"
|
||||
},
|
||||
"readme": "# querystring #\n\nNode's querystring module for all engines.\n\n## Install ##\n\n npm install querystring\n\n",
|
||||
"readmeFilename": "Readme.md",
|
||||
"_id": "querystring@0.1.0",
|
||||
"dist": {
|
||||
"shasum": "210af37f82b5fa9a52a05982a2b27607e97c01bb"
|
||||
},
|
||||
"_from": "querystring"
|
||||
}
|
||||
108
test/node_modules/querystring/querystring.js
generated
vendored
Normal file
108
test/node_modules/querystring/querystring.js
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// 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.
|
||||
|
||||
// Query String Utilities
|
||||
|
||||
(typeof define === "undefined" ? function($) { $(require, exports, module) } : define)(function(require, exports, module, undefined) {
|
||||
"use strict";
|
||||
|
||||
var QueryString = exports;
|
||||
|
||||
function charCode(c) {
|
||||
return c.charCodeAt(0);
|
||||
}
|
||||
|
||||
QueryString.unescape = decodeURIComponent;
|
||||
QueryString.escape = encodeURIComponent;
|
||||
|
||||
var stringifyPrimitive = function(v) {
|
||||
switch (typeof v) {
|
||||
case 'string':
|
||||
return v;
|
||||
|
||||
case 'boolean':
|
||||
return v ? 'true' : 'false';
|
||||
|
||||
case 'number':
|
||||
return isFinite(v) ? v : '';
|
||||
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
QueryString.stringify = QueryString.encode = function(obj, sep, eq, name) {
|
||||
sep = sep || '&';
|
||||
eq = eq || '=';
|
||||
obj = (obj === null) ? undefined : obj;
|
||||
|
||||
switch (typeof obj) {
|
||||
case 'object':
|
||||
return Object.keys(obj).map(function(k) {
|
||||
if (Array.isArray(obj[k])) {
|
||||
return obj[k].map(function(v) {
|
||||
return QueryString.escape(stringifyPrimitive(k)) +
|
||||
eq +
|
||||
QueryString.escape(stringifyPrimitive(v));
|
||||
}).join(sep);
|
||||
} else {
|
||||
return QueryString.escape(stringifyPrimitive(k)) +
|
||||
eq +
|
||||
QueryString.escape(stringifyPrimitive(obj[k]));
|
||||
}
|
||||
}).join(sep);
|
||||
|
||||
default:
|
||||
if (!name) return '';
|
||||
return QueryString.escape(stringifyPrimitive(name)) + eq +
|
||||
QueryString.escape(stringifyPrimitive(obj));
|
||||
}
|
||||
};
|
||||
|
||||
// Parse a key=val string.
|
||||
QueryString.parse = QueryString.decode = function(qs, sep, eq) {
|
||||
sep = sep || '&';
|
||||
eq = eq || '=';
|
||||
var obj = {};
|
||||
|
||||
if (typeof qs !== 'string' || qs.length === 0) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
qs.split(sep).forEach(function(kvp) {
|
||||
var x = kvp.split(eq);
|
||||
var k = QueryString.unescape(x[0], true);
|
||||
var v = QueryString.unescape(x.slice(1).join(eq), true);
|
||||
|
||||
if (!(k in obj)) {
|
||||
obj[k] = v;
|
||||
} else if (!Array.isArray(obj[k])) {
|
||||
obj[k] = [obj[k], v];
|
||||
} else {
|
||||
obj[k].push(v);
|
||||
}
|
||||
});
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
});
|
||||
BIN
test/node_modules/querystring/tests/.test-querystring.js.un~
generated
vendored
Normal file
BIN
test/node_modules/querystring/tests/.test-querystring.js.un~
generated
vendored
Normal file
Binary file not shown.
203
test/node_modules/querystring/tests/test-querystring.js
generated
vendored
Normal file
203
test/node_modules/querystring/tests/test-querystring.js
generated
vendored
Normal file
@@ -0,0 +1,203 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// 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.
|
||||
|
||||
"use strict";
|
||||
|
||||
// test using assert
|
||||
var qs = require('../querystring');
|
||||
|
||||
// folding block, commented to pass gjslint
|
||||
// {{{
|
||||
// [ wonkyQS, canonicalQS, obj ]
|
||||
var qsTestCases = [
|
||||
['foo=918854443121279438895193',
|
||||
'foo=918854443121279438895193',
|
||||
{'foo': '918854443121279438895193'}],
|
||||
['foo=bar', 'foo=bar', {'foo': 'bar'}],
|
||||
['foo=bar&foo=quux', 'foo=bar&foo=quux', {'foo': ['bar', 'quux']}],
|
||||
['foo=1&bar=2', 'foo=1&bar=2', {'foo': '1', 'bar': '2'}],
|
||||
// ['my+weird+field=q1%212%22%27w%245%267%2Fz8%29%3F',
|
||||
// 'my%20weird%20field=q1!2%22\'w%245%267%2Fz8)%3F',
|
||||
// {'my weird field': 'q1!2"\'w$5&7/z8)?' }],
|
||||
['foo%3Dbaz=bar', 'foo%3Dbaz=bar', {'foo=baz': 'bar'}],
|
||||
['foo=baz=bar', 'foo=baz%3Dbar', {'foo': 'baz=bar'}],
|
||||
['str=foo&arr=1&arr=2&arr=3&somenull=&undef=',
|
||||
'str=foo&arr=1&arr=2&arr=3&somenull=&undef=',
|
||||
{ 'str': 'foo',
|
||||
'arr': ['1', '2', '3'],
|
||||
'somenull': '',
|
||||
'undef': ''}],
|
||||
[' foo = bar ', '%20foo%20=%20bar%20', {' foo ': ' bar '}],
|
||||
// disable test that fails ['foo=%zx', 'foo=%25zx', {'foo': '%zx'}],
|
||||
['foo=%EF%BF%BD', 'foo=%EF%BF%BD', {'foo': '\ufffd' }]
|
||||
];
|
||||
|
||||
// [ wonkyQS, canonicalQS, obj ]
|
||||
var qsColonTestCases = [
|
||||
['foo:bar', 'foo:bar', {'foo': 'bar'}],
|
||||
['foo:bar;foo:quux', 'foo:bar;foo:quux', {'foo': ['bar', 'quux']}],
|
||||
['foo:1&bar:2;baz:quux',
|
||||
'foo:1%26bar%3A2;baz:quux',
|
||||
{'foo': '1&bar:2', 'baz': 'quux'}],
|
||||
['foo%3Abaz:bar', 'foo%3Abaz:bar', {'foo:baz': 'bar'}],
|
||||
['foo:baz:bar', 'foo:baz%3Abar', {'foo': 'baz:bar'}]
|
||||
];
|
||||
|
||||
// [wonkyObj, qs, canonicalObj]
|
||||
var extendedFunction = function() {};
|
||||
extendedFunction.prototype = {a: 'b'};
|
||||
var qsWeirdObjects = [
|
||||
[{regexp: /./g}, 'regexp=', {'regexp': ''}],
|
||||
[{regexp: new RegExp('.', 'g')}, 'regexp=', {'regexp': ''}],
|
||||
[{fn: function() {}}, 'fn=', {'fn': ''}],
|
||||
[{fn: new Function('')}, 'fn=', {'fn': ''}],
|
||||
[{math: Math}, 'math=', {'math': ''}],
|
||||
[{e: extendedFunction}, 'e=', {'e': ''}],
|
||||
[{d: new Date()}, 'd=', {'d': ''}],
|
||||
[{d: Date}, 'd=', {'d': ''}],
|
||||
[{f: new Boolean(false), t: new Boolean(true)}, 'f=&t=', {'f': '', 't': ''}],
|
||||
[{f: false, t: true}, 'f=false&t=true', {'f': 'false', 't': 'true'}],
|
||||
[{n: null}, 'n=', {'n': ''}],
|
||||
[{nan: NaN}, 'nan=', {'nan': ''}],
|
||||
[{inf: Infinity}, 'inf=', {'inf': ''}]
|
||||
];
|
||||
// }}}
|
||||
|
||||
var qsNoMungeTestCases = [
|
||||
['', {}],
|
||||
['foo=bar&foo=baz', {'foo': ['bar', 'baz']}],
|
||||
['blah=burp', {'blah': 'burp'}],
|
||||
['gragh=1&gragh=3&goo=2', {'gragh': ['1', '3'], 'goo': '2'}],
|
||||
['frappucino=muffin&goat%5B%5D=scone&pond=moose',
|
||||
{'frappucino': 'muffin', 'goat[]': 'scone', 'pond': 'moose'}],
|
||||
['trololol=yes&lololo=no', {'trololol': 'yes', 'lololo': 'no'}]
|
||||
];
|
||||
|
||||
exports['test basic'] = function(assert) {
|
||||
assert.strictEqual('918854443121279438895193',
|
||||
qs.parse('id=918854443121279438895193').id,
|
||||
'prase id=918854443121279438895193');
|
||||
};
|
||||
|
||||
exports['test that the canonical qs is parsed properly'] = function(assert) {
|
||||
qsTestCases.forEach(function(testCase) {
|
||||
assert.deepEqual(testCase[2], qs.parse(testCase[0]),
|
||||
'parse ' + testCase[0]);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
exports['test that the colon test cases can do the same'] = function(assert) {
|
||||
qsColonTestCases.forEach(function(testCase) {
|
||||
assert.deepEqual(testCase[2], qs.parse(testCase[0], ';', ':'),
|
||||
'parse ' + testCase[0] + ' -> ; :');
|
||||
});
|
||||
};
|
||||
|
||||
exports['test the weird objects, that they get parsed properly'] = function(assert) {
|
||||
qsWeirdObjects.forEach(function(testCase) {
|
||||
assert.deepEqual(testCase[2], qs.parse(testCase[1]),
|
||||
'parse ' + testCase[1]);
|
||||
});
|
||||
};
|
||||
|
||||
exports['test non munge test cases'] = function(assert) {
|
||||
qsNoMungeTestCases.forEach(function(testCase) {
|
||||
assert.deepEqual(testCase[0], qs.stringify(testCase[1], '&', '=', false),
|
||||
'stringify ' + JSON.stringify(testCase[1]) + ' -> & =');
|
||||
});
|
||||
};
|
||||
|
||||
exports['test the nested qs-in-qs case'] = function(assert) {
|
||||
var f = qs.parse('a=b&q=x%3Dy%26y%3Dz');
|
||||
f.q = qs.parse(f.q);
|
||||
assert.deepEqual(f, { a: 'b', q: { x: 'y', y: 'z' } },
|
||||
'parse a=b&q=x%3Dy%26y%3Dz');
|
||||
};
|
||||
|
||||
exports['test nested in colon'] = function(assert) {
|
||||
var f = qs.parse('a:b;q:x%3Ay%3By%3Az', ';', ':');
|
||||
f.q = qs.parse(f.q, ';', ':');
|
||||
assert.deepEqual(f, { a: 'b', q: { x: 'y', y: 'z' } },
|
||||
'parse a:b;q:x%3Ay%3By%3Az -> ; :');
|
||||
};
|
||||
|
||||
exports['test stringifying'] = function(assert) {
|
||||
qsTestCases.forEach(function(testCase) {
|
||||
assert.equal(testCase[1], qs.stringify(testCase[2]),
|
||||
'stringify ' + JSON.stringify(testCase[2]));
|
||||
});
|
||||
|
||||
qsColonTestCases.forEach(function(testCase) {
|
||||
assert.equal(testCase[1], qs.stringify(testCase[2], ';', ':'),
|
||||
'stringify ' + JSON.stringify(testCase[2]) + ' -> ; :');
|
||||
});
|
||||
|
||||
qsWeirdObjects.forEach(function(testCase) {
|
||||
assert.equal(testCase[1], qs.stringify(testCase[0]),
|
||||
'stringify ' + JSON.stringify(testCase[0]));
|
||||
});
|
||||
};
|
||||
|
||||
exports['test stringifying nested'] = function(assert) {
|
||||
var f = qs.stringify({
|
||||
a: 'b',
|
||||
q: qs.stringify({
|
||||
x: 'y',
|
||||
y: 'z'
|
||||
})
|
||||
});
|
||||
assert.equal(f, 'a=b&q=x%3Dy%26y%3Dz',
|
||||
JSON.stringify({
|
||||
a: 'b',
|
||||
'qs.stringify -> q': {
|
||||
x: 'y',
|
||||
y: 'z'
|
||||
}
|
||||
}));
|
||||
|
||||
var threw = false;
|
||||
try { qs.parse(undefined); } catch(error) { threw = true; }
|
||||
assert.ok(!threw, "does not throws on undefined");
|
||||
};
|
||||
|
||||
exports['test nested in colon'] = function(assert) {
|
||||
var f = qs.stringify({
|
||||
a: 'b',
|
||||
q: qs.stringify({
|
||||
x: 'y',
|
||||
y: 'z'
|
||||
}, ';', ':')
|
||||
}, ';', ':');
|
||||
assert.equal(f, 'a:b;q:x%3Ay%3By%3Az',
|
||||
'stringify ' + JSON.stringify({
|
||||
a: 'b',
|
||||
'qs.stringify -> q': {
|
||||
x: 'y',
|
||||
y: 'z'
|
||||
}
|
||||
}) + ' -> ; : ');
|
||||
|
||||
|
||||
assert.deepEqual({}, qs.parse(), 'parse undefined');
|
||||
};
|
||||
|
||||
require("test").run(exports);
|
||||
Reference in New Issue
Block a user