querystring: fix maxKeys = 0 is ignored
This commit is contained in:
parent
f1678bfc65
commit
23de33968f
@ -164,7 +164,12 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq, options) {
|
||||
sep = sep || '&';
|
||||
eq = eq || '=';
|
||||
var obj = {},
|
||||
maxKeys = options && options.maxKeys || 1000;
|
||||
maxKeys = 1000;
|
||||
|
||||
// Handle maxKeys = 0 case
|
||||
if (options && typeof options.maxKeys === 'number') {
|
||||
maxKeys = options.maxKeys;
|
||||
}
|
||||
|
||||
if (typeof qs !== 'string' || qs.length === 0) {
|
||||
return obj;
|
||||
|
@ -189,6 +189,22 @@ assert.equal(
|
||||
1
|
||||
);
|
||||
|
||||
// Test removing limit
|
||||
function testUnlimitedKeys() {
|
||||
var query = {},
|
||||
url;
|
||||
|
||||
for (var i = 0; i < 2000; i++) query[i] = i;
|
||||
|
||||
url = qs.stringify(query);
|
||||
|
||||
assert.equal(
|
||||
Object.keys(qs.parse(url, null, null, { maxKeys: 0 })).length,
|
||||
2000
|
||||
);
|
||||
}
|
||||
testUnlimitedKeys();
|
||||
|
||||
|
||||
var b = qs.unescapeBuffer('%d3%f2Ug%1f6v%24%5e%98%cb' +
|
||||
'%0d%ac%a2%2f%9d%eb%d8%a2%e6');
|
||||
|
Loading…
x
Reference in New Issue
Block a user