Created
June 15, 2011 09:36
-
-
Save barneycarroll/1026798 to your computer and use it in GitHub Desktop.
Return an object model of a URI query (search or hash)
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
| /* Return an object model of a URI query (search or hash) */ | |
| function uriQueryObj(str){ | |
| if(!str) return false; | |
| var str = decodeURIComponent(str), | |
| str = /(^#)|(^$)/.test(str) ? str.substr(1) : str, | |
| arr = str.substr(1).split('&'), | |
| hash = {}; | |
| while(arr.length && arr[0]){ | |
| var bits = arr.pop().split('=') | |
| hash[bits[0]] = bits[1] || bits[0]; | |
| } | |
| return hash; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment