Last active
December 20, 2015 22:38
-
-
Save kodaka/6206283 to your computer and use it in GitHub Desktop.
Parse QUERY_STRING.
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
// "?a=1&a=2&b=x&c=%2A&d=&=y&=&==&%2A=3&" -> Object {a: "2", b: "x", c: "*", d: "", %2A: "3"} | |
var q = (function(){ | |
var q = {}; | |
window.location.search | |
.substring(1) | |
.split('&') | |
.filter(function(a){ | |
return a.indexOf('=') > 0; | |
}) | |
.forEach(function(a){ | |
var p = a.split('='); | |
q[p[0].trim()] = decodeURIComponent(p[1]).trim(); | |
}) | |
; | |
return q; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment