Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' of https://github.com/nodejs/node
# Conflicts:
#	test/parallel/test-querystring.js
  • Loading branch information
lukaszewczak committed Sep 20, 2017
commit 4598d487ddb9894418a4e52dfeb2227c6b6a8cf4
40 changes: 21 additions & 19 deletions test/parallel/test-querystring.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,25 +338,25 @@ assert.strictEqual(

// Test removing limit
{
const testUnlimitedKeys = function() {
function testUnlimitedKeys() {
const query = {};

for (let i = 0; i < 2000; i++) query[i] = i;

const url = qs.stringify(query);

assert.strictEqual(
Object.keys(qs.parse(url, null, null, {maxKeys: 0})).length,
Object.keys(qs.parse(url, null, null, { maxKeys: 0 })).length,
2000);
};
}

testUnlimitedKeys();
}

{
const b = qs.unescapeBuffer('%d3%f2Ug%1f6v%24%5e%98%cb' +
'%0d%ac%a2%2f%9d%eb%d8%a2%e6');
// <Buffer d3 f2 55 67 1f 36 76 24 5e 98 cb 0d ac a2 2f 9d eb d8 a2 e6>
// <Buffer d3 f2 55 67 1f 36 76 24 5e 98 cb 0d ac a2 2f 9d eb d8 a2 e6>
assert.strictEqual(0xd3, b[0]);
assert.strictEqual(0xf2, b[1]);
assert.strictEqual(0x55, b[2]);
Expand Down Expand Up @@ -392,35 +392,37 @@ check(qs.parse('%\u0100=%\u0101'), { '%Ā': '%ā' });

// Test custom decode
{
const demoDecode = function(str) {
function demoDecode(str) {
return str + str;
};
}

check(qs.parse('a=a&b=b&c=c', null, null, {decodeURIComponent: demoDecode}),
{aa: 'aa', bb: 'bb', cc: 'cc'});
check(qs.parse('a=a&b=b&c=c', null, '==', {decodeURIComponent: (str) => str}),
{'a=a': '', 'b=b': '', 'c=c': ''});
check(
qs.parse('a=a&b=b&c=c', null, null, { decodeURIComponent: demoDecode }),
{ aa: 'aa', bb: 'bb', cc: 'cc' });
check(
qs.parse('a=a&b=b&c=c', null, '==', { decodeURIComponent: (str) => str }),
{ 'a=a': '', 'b=b': '', 'c=c': '' });
}

// Test QueryString.unescape
{
const errDecode = function(str) {
function errDecode(str) {
throw new Error('To jump to the catch scope');
};
}

check(qs.parse('a=a', null, null, {decodeURIComponent: errDecode}),
{a: 'a'});
check(qs.parse('a=a', null, null, { decodeURIComponent: errDecode }),
{ a: 'a' });
}

// Test custom encode
{
const demoEncode = function(str) {
function demoEncode(str) {
return str[0];
};
}

const obj = {aa: 'aa', bb: 'bb', cc: 'cc'};
const obj = { aa: 'aa', bb: 'bb', cc: 'cc' };
assert.strictEqual(
qs.stringify(obj, null, null, {encodeURIComponent: demoEncode}),
qs.stringify(obj, null, null, { encodeURIComponent: demoEncode }),
'a=a&b=b&c=c');
}

Expand All @@ -438,7 +440,7 @@ qsUnescapeTestCases.forEach(function(testCase) {
};
check(
qs.parse('foo=bor'),
createWithNoPrototype([{key: 'f__', value: 'b_r'}]));
createWithNoPrototype([{ key: 'f__', value: 'b_r' }]));
qs.unescape = prevUnescape;
}
// test separator and "equals" parsing order
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.