Skip to content

Instantly share code, notes, and snippets.

@igroff
Last active August 29, 2015 14:11
Show Gist options
  • Select an option

  • Save igroff/d60171e1b68ccfcae4b8 to your computer and use it in GitHub Desktop.

Select an option

Save igroff/d60171e1b68ccfcae4b8 to your computer and use it in GitHub Desktop.
/* The idea here is that we take something that's formatted like a query string, and
return a dictionary (object) it represents
*/
function qsLikeToObj(qsLike){
var obj = {};
qsLike.replace(
new RegExp("([^?=&]+)(=([^&]*))?", "g"),
function($0, $1, $2, $3) { obj[$1] = $3; }
);
return obj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment