Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

482 B
Raw Blame
/**
 * Parse the given `qs`.
 *
 * @private
 * @param {string} qs
 * @return {Object<string, string>}
 */
export function parseQuery(qs) {
  return qs
    .replace("?", "")
    .split("&")
    .reduce(function (obj, pair) {
      var i = pair.indexOf("=");
      var key = pair.slice(0, i);
      var val = pair.slice(i + 1);

      // Due to how the URLSearchParams API treats spaces
      obj[key] = decodeURIComponent(val.replace(/\+/g, "%20"));

      return obj;
    }, {});
}