-
-
Save marteinn/2819093 to your computer and use it in GitHub Desktop.
jQuery.parseParams - parse query string paramaters into an object (jshint compatible)
This file contains 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
/** | |
* $.parseParams - parse query string paramaters into an object. | |
*/ | |
/*jshint regexp: false */ | |
(function($) { | |
var re = /([^&=]+)=?([^&]*)/g; | |
var decodeRE = /\+/g; // Regex for replacing addition symbol with a space | |
var decode = function (str) { return decodeURIComponent( str.replace(decodeRE, " ") ); }; | |
$.parseParams = function(query) { | |
var params = {}, e; | |
while ( (e = re.exec(query)) ) | |
{ | |
params[decode(e[1])] = decode(e[2]); | |
} | |
return params; | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment