test: add two test cases for querystring
+ Check an empty substring: In `querystring`, if the `maxKeys` is 1 and the state machine finds an empty substring between separators, it should return an empty object. + Test invalid encoded strings: If provided string is an invalid encoded string in `query.parse`, it will not be encoded. PR-URL: https://github.com/nodejs/node/pull/11481 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
5da952472b
commit
dd2e135560
@ -288,6 +288,11 @@ assert.strictEqual(
|
||||
Object.keys(qs.parse('a=1&b=1&c=1', null, null, { maxKeys: 1 })).length,
|
||||
1);
|
||||
|
||||
// Test limiting with a case that starts from `&`
|
||||
assert.strictEqual(
|
||||
Object.keys(qs.parse('&a', null, null, { maxKeys: 1 })).length,
|
||||
0);
|
||||
|
||||
// Test removing limit
|
||||
function testUnlimitedKeys() {
|
||||
const query = {};
|
||||
@ -334,6 +339,8 @@ assert.strictEqual(qs.unescapeBuffer('a%20').toString(), 'a ');
|
||||
assert.strictEqual(qs.unescapeBuffer('a%2g').toString(), 'a%2g');
|
||||
assert.strictEqual(qs.unescapeBuffer('a%%').toString(), 'a%%');
|
||||
|
||||
// Test invalid encoded string
|
||||
check(qs.parse('%\u0100=%\u0101'), { '%Ā': '%ā' });
|
||||
|
||||
// Test custom decode
|
||||
function demoDecode(str) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user