Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Fix #3058 querystring: Fix incorrect handling of empty keys
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed May 11, 2012
1 parent 12fc9fa commit a811a4a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/querystring.js
Expand Up @@ -189,6 +189,11 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq, options) {
kstr = x.substring(0, idx),
vstr = x.substring(idx + 1), k, v;

if (kstr === '' && vstr !== '') {
kstr = vstr;
vstr = '';
}

try {
k = decodeURIComponent(kstr);
v = decodeURIComponent(vstr);
Expand Down
4 changes: 3 additions & 1 deletion test/simple/test-querystring.js
Expand Up @@ -55,7 +55,9 @@ var qsTestCases = [
{ hasOwnProperty: 'x',
toString: 'foo',
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 ]
Expand Down

0 comments on commit a811a4a

Please sign in to comment.