Skip to content

Instantly share code, notes, and snippets.

@mrself
Last active September 9, 2015 07:32
Show Gist options
  • Save mrself/bf0636812be27a2b0186 to your computer and use it in GitHub Desktop.
Save mrself/bf0636812be27a2b0186 to your computer and use it in GitHub Desktop.
(function($) {
$.parseQueryString = function(query) {
query = query || document.location.search;
if (!query) return null;
query = query.replace('?', '').split('&');
var i, part, property, val, params = {};
for (i = 0; i < query.length; i++) {
part = query[i].split('=');
property = part[0];
val = part[1];
if (property.substr(-2) == '[]') {
var arName = property.slice(0, -2);
(params[arName] || (params[arName] = [])).push(val);
} else {
params[property] = val;
}
}
return params;
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment