getParams: function()

in app/core/utils.js [27:52]


  getParams: function (queryString) {
    if (queryString) {
      // I think this could be combined into one if
      if (queryString.substring(0, 1) === '?') {
        queryString = queryString.substring(1);
      } else if (queryString.indexOf('?') > -1) {
        queryString = queryString.split('?')[1];
      }
    }
    const hash = window.location.hash.split('?')[1];
    queryString = queryString || hash || window.location.search.substring(1);
    const urlParams = {},
          pl = /\+/g,  // Regex for replacing addition symbol with a space
          search = /([^&=]+)=?([^&]*)/g,
          decode = function (s) { return decodeURIComponent(s.replace(pl, ' ')); },
          query = queryString;

    if (queryString) {
      let match;
      while ((match = search.exec(query))) {
        urlParams[decode(match[1])] = decode(match[2]);
      }
    }

    return urlParams;
  },