|
|
@ -175,6 +175,7 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq, options) { |
|
|
|
return obj; |
|
|
|
} |
|
|
|
|
|
|
|
var regexp = /\+/g; |
|
|
|
qs = qs.split(sep); |
|
|
|
|
|
|
|
// maxKeys <= 0 means that we should not limit keys count
|
|
|
@ -182,17 +183,18 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq, options) { |
|
|
|
qs = qs.slice(0, maxKeys); |
|
|
|
} |
|
|
|
|
|
|
|
qs.forEach(function(kvp) { |
|
|
|
var x = kvp.split(eq), k, v, useQS = false; |
|
|
|
for (var i = 0, len = qs.length; i < len; ++i) { |
|
|
|
var x = qs[i].replace(regexp, '%20'), |
|
|
|
idx = x.indexOf(eq), |
|
|
|
kstr = x.substring(0, idx), |
|
|
|
vstr = x.substring(idx + 1), k, v; |
|
|
|
|
|
|
|
try { |
|
|
|
if (kvp.match(/\+/)) { // decodeURIComponent does not decode + to space
|
|
|
|
throw 'has +'; |
|
|
|
} |
|
|
|
k = decodeURIComponent(x[0]); |
|
|
|
v = decodeURIComponent(x.slice(1).join(eq) || ''); |
|
|
|
} catch (e) { |
|
|
|
k = QueryString.unescape(x[0], true); |
|
|
|
v = QueryString.unescape(x.slice(1).join(eq), true); |
|
|
|
k = decodeURIComponent(kstr); |
|
|
|
v = decodeURIComponent(vstr); |
|
|
|
} catch(e) { |
|
|
|
k = QueryString.unescape(kstr, true); |
|
|
|
v = QueryString.unescape(vstr, true); |
|
|
|
} |
|
|
|
|
|
|
|
if (!hasOwnProperty(obj, k)) { |
|
|
@ -202,7 +204,7 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq, options) { |
|
|
|
} else { |
|
|
|
obj[k].push(v); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
return obj; |
|
|
|
}; |
|
|
|