Commit 5f938355 authored by Simon Knox's avatar Simon Knox

simplify urlParamsToObject

parent 4b1b5b0d
......@@ -152,19 +152,19 @@ export const urlParamsToObject = (path = '') => splitPath(path)
}
const data = dataParam;
const paramSplit = filterParam.split('=');
const paramKeyNormalized = paramSplit[0].replace('[]', '');
const isArray = paramSplit[0].indexOf('[]');
const value = decodeURIComponent(paramSplit[1].replace(/\+/g, ' '));
if (isArray !== -1) {
if (!data[paramKeyNormalized]) {
data[paramKeyNormalized] = [];
let [key, value] = filterParam.split('=');
const isArray = key.includes('[]');
key = key.replace('[]', '');
value = decodeURIComponent(value.replace(/\+/g, ' '));
if (isArray) {
if (!data[key]) {
data[key] = [];
}
data[paramKeyNormalized].push(value);
data[key].push(value);
} else {
data[paramKeyNormalized] = value;
data[key] = value;
}
return data;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment