Fix #3058 querystring: Fix incorrect handling of empty keys
This commit is contained in:
parent
12fc9fa8a7
commit
a811a4a130
@ -189,6 +189,11 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq, options) {
|
|||||||
kstr = x.substring(0, idx),
|
kstr = x.substring(0, idx),
|
||||||
vstr = x.substring(idx + 1), k, v;
|
vstr = x.substring(idx + 1), k, v;
|
||||||
|
|
||||||
|
if (kstr === '' && vstr !== '') {
|
||||||
|
kstr = vstr;
|
||||||
|
vstr = '';
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
k = decodeURIComponent(kstr);
|
k = decodeURIComponent(kstr);
|
||||||
v = decodeURIComponent(vstr);
|
v = decodeURIComponent(vstr);
|
||||||
|
@ -55,7 +55,9 @@ var qsTestCases = [
|
|||||||
{ hasOwnProperty: 'x',
|
{ hasOwnProperty: 'x',
|
||||||
toString: 'foo',
|
toString: 'foo',
|
||||||
valueOf: 'bar',
|
valueOf: 'bar',
|
||||||
__defineGetter__: 'baz' }]
|
__defineGetter__: 'baz' }],
|
||||||
|
// See: https://github.com/joyent/node/issues/3058
|
||||||
|
['foo&bar=baz', 'foo=&bar=baz', { foo: '', bar: 'baz' }]
|
||||||
];
|
];
|
||||||
|
|
||||||
// [ wonkyQS, canonicalQS, obj ]
|
// [ wonkyQS, canonicalQS, obj ]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user