UNPKG

@regang/keen-core

Version:

Core functionality powering Keen IO's modular JavaScript SDKs

17 lines (14 loc) 509 B
module.exports = parseParams; function parseParams(str){ // via: http://stackoverflow.com/a/2880929/2511985 var urlParams = {}, match, pl = /\+/g, // Regex for replacing addition symbol with a space search = /([^&=]+)=?([^&]*)/g, decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); }, query = str.split("?")[1]; while (!!(match=search.exec(query))) { urlParams[decode(match[1])] = decode(match[2]); } return urlParams; };