js: Fix improper parsing in `utils.parseParams()`

This commit is contained in:
Johannes Meyer 2020-01-15 16:46:46 +01:00
parent db69f23c20
commit 3db65d79c6
1 changed files with 17 additions and 4 deletions

View File

@ -198,15 +198,28 @@
segment = a.search.replace(/^\?/,'').split('&'),
len = segment.length,
i = 0,
s;
s,
key,
value,
equalPos;
for (; i < len; i++) {
if (!segment[i]) {
if (! segment[i]) {
continue;
}
s = segment[i].split('=');
params[decodeURIComponent(s[0])] = typeof s[1] !== 'undefined' ? decodeURIComponent(s[1]) : null;
equalPos = segment[i].indexOf('=');
if (equalPos !== -1) {
key = segment[i].slice(0, equalPos);
value = segment[i].slice(equalPos + 1);
} else {
key = segment[i];
value = null;
}
params[key] = value;
}
return params;
},