debian-mirror-gitlab/app/assets/javascripts/boards/utils/query_data.js

22 lines
617 B
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05:30
export default (path, extraData) => path.split('&').reduce((dataParam, filterParam) => {
if (filterParam === '') return dataParam;
const data = dataParam;
const paramSplit = filterParam.split('=');
const paramKeyNormalized = paramSplit[0].replace('[]', '');
const isArray = paramSplit[0].indexOf('[]');
2018-03-17 18:26:18 +05:30
const value = decodeURIComponent(paramSplit[1].replace(/\+/g, ' '));
2017-08-17 22:00:37 +05:30
if (isArray !== -1) {
if (!data[paramKeyNormalized]) {
data[paramKeyNormalized] = [];
}
data[paramKeyNormalized].push(value);
} else {
data[paramKeyNormalized] = value;
}
return data;
}, extraData);