Skip to content

Instantly share code, notes, and snippets.

@zbicin
Created October 15, 2015 19:58
Show Gist options
  • Select an option

  • Save zbicin/72aa8fc4c3e97f7321bc to your computer and use it in GitHub Desktop.

Select an option

Save zbicin/72aa8fc4c3e97f7321bc to your computer and use it in GitHub Desktop.
A snippet serving URL parameters as an object
function parseUrlParameters() {
var result = {};
var keyValueCombined = location.search.substr(1).split('&');
for(var i = 0; i<keyValueCombined.length; i++) {
var splitted = keyValueCombined[i].split('=');
var key = splitted[0];
var value = splitted.slice(1).join('=');
result[key] = value;
}
if(result[''] !== undefined && result[''] === '') {
delete result[''];
}
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment