Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Parse url parameters from any string given or from current URL otherwise
// Adapted from
function parseUrlParams(queryString) {
var params = {},
pl = /\+/g, // Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g,
decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
query = queryString ||;
while (match = search.exec(query))
params[decode(match[1])] = decode(match[2]);
return params;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment