Skip to content

Instantly share code, notes, and snippets.

@framingeinstein
Created August 8, 2018 03:48
Show Gist options
  • Save framingeinstein/66814d3d63af85e3d3cdc664e827102d to your computer and use it in GitHub Desktop.
Save framingeinstein/66814d3d63af85e3d3cdc664e827102d to your computer and use it in GitHub Desktop.
function parseQuery(href){
var qo = {};
var parts = href.split('?');
var query = [];
if(parts.length > 1){
query = parts[1].split('&');
}
if(query.length > 0){
if(query[0] == ""){
query.shift();
}
for(var i = 0; i < query.length; i++){
var kv = query[i].split('=')
qo[kv[0]] = '';
if(kv.length > 1){
qo[kv[0]] = kv[1];
}
}
}
return qo;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment