-
-
Save joemar-tagpuno/a2adbf233cfb385de54180b31e9e8d4a to your computer and use it in GitHub Desktop.
jQuery.deparam - The oposite of jQuery param. Creates an object of query string parameters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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] = $3; } | |
| ); | |
| return queryString; | |
| }; | |
| })(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment