Skip to content

Instantly share code, notes, and snippets.

@andrewjmead
Last active October 19, 2020 13:37
Show Gist options
  • Star 40 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • Save andrewjmead/b71e03d8df237983285892f9a265d401 to your computer and use it in GitHub Desktop.
Save andrewjmead/b71e03d8df237983285892f9a265d401 to your computer and use it in GitHub Desktop.
/**
* jQuery.deparam - The oposite of jQuery param. Creates an object of query string parameters.
*
* Credits for the idea and Regex:
* http://stevenbenner.com/2010/03/javascript-regex-trick-parse-a-query-string-into-an-object/
*/
(function($){
$.deparam = $.deparam || function(uri){
if(uri === undefined){
uri = window.location.search;
}
var queryString = {};
uri.replace(
new RegExp(
"([^?=&]+)(=([^&#]*))?", "g"),
function($0, $1, $2, $3) {
queryString[$1] = decodeURIComponent($3.replace(/\+/g, '%20'));
}
);
return queryString;
};
})(jQuery);
@avvvet
Copy link

avvvet commented Nov 24, 2018

yep ! cool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment