verdnatura-chat/app/lib/methods/helpers/parseQuery.js

8 lines
273 B
JavaScript
Raw Normal View History

export default function (query) {
return (/^[?#]/.test(query) ? query.slice(1) : query).split('&').reduce((params, param) => {
const [key, value] = param.split('=');
params[key] = value ? decodeURIComponent(value.replace(/\+/g, ' ')) : '';
return params;
}, {});
}