Skip to content

Instantly share code, notes, and snippets.

@husa
Last active August 29, 2015 14:07
Show Gist options
  • Save husa/b687e7f0d06f83865933 to your computer and use it in GitHub Desktop.
Save husa/b687e7f0d06f83865933 to your computer and use it in GitHub Desktop.
get URL params from string
function getURLParams(url, includeEmptyValues) {
return decodeURIComponent(url || window.location.search.slice(1)).
replace(/.*\?/, '').split('&').
reduce((params, value) => {
value = value.split('=')
if (includeEmptyValues || typeof value[1] !== 'undefined')
params[value[0]] = value[1];
return params;
}, {});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment