Skip to content

Commit

Permalink
test: add two test cases for querystring
Browse files Browse the repository at this point in the history
+ 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: nodejs/node#11481
Reviewed-By: Timothy Gu <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
watilde authored and jasnell committed Feb 24, 2017
1 parent 5da9524 commit dd2e135
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/parallel/test-querystring.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit dd2e135

Please sign in to comment.