Merge branch 'hotfix/21.56.9' into master
[gitter.git] / modules / qs / parse.js
blob7079c1381cd06a448d9ac17aa41c8c8b2a1adf3a
1 /* eslint-env browser */
2 'use strict';
4 // "?foo=bar&fish=chips" -> { foo: bar, fish: chips }
5 var parse = function(qs) {
6 if (!qs || qs.length <= 1) return {};
8 return qs
9 .substring(1)
10 .split('&')
11 .reduce(function(memo, pair) {
12 var splitPair = pair.split('=', 2).map(decodeURIComponent);
14 memo[splitPair[0]] = splitPair[1];
15 return memo;
16 }, {});
19 let currentWindowSearch = '';
20 if (typeof window !== 'undefined') {
21 currentWindowSearch = window.location.search;
24 module.exports = parse(currentWindowSearch);