2017-03-15 07:23:43 -04:00
|
|
|
export default (path, extraData) => path.split('&').reduce((dataParam, filterParam) => {
|
|
|
|
if (filterParam === '') return dataParam;
|
2017-03-15 06:52:49 -04:00
|
|
|
|
2017-03-15 07:23:43 -04:00
|
|
|
const data = dataParam;
|
|
|
|
const paramSplit = filterParam.split('=');
|
|
|
|
const paramKeyNormalized = paramSplit[0].replace('[]', '');
|
|
|
|
const isArray = paramSplit[0].indexOf('[]');
|
|
|
|
const value = decodeURIComponent(paramSplit[1]).replace(/\+/g, ' ');
|
2017-03-15 06:52:49 -04:00
|
|
|
|
2017-03-15 07:23:43 -04:00
|
|
|
if (isArray !== -1) {
|
|
|
|
if (!data[paramKeyNormalized]) {
|
|
|
|
data[paramKeyNormalized] = [];
|
2017-03-15 06:52:49 -04:00
|
|
|
}
|
|
|
|
|
2017-03-15 07:23:43 -04:00
|
|
|
data[paramKeyNormalized].push(value);
|
|
|
|
} else {
|
|
|
|
data[paramKeyNormalized] = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}, extraData);
|