-
-
Save flisky/1681990 to your computer and use it in GitHub Desktop.
add support to same key occurred multi times
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
jQuery.extend({ | |
parseQuerystring: function(){ | |
var nvpair = {}; | |
var qs = window.location.search.replace('?', ''); | |
var pairs = decodeURI(qs).split('&'); | |
$.each(pairs, function(i, v){ | |
var pair = v.split('='); | |
var key = pair[0], value = pair[1]; | |
if(key in nvpair){ | |
if(!$.isArray(nvpair[key])){ nvpair[key] = $.makeArray(nvpair[key]);} | |
nvpair[key].push(value); | |
} else { | |
nvpair[key] = value; | |
} | |
}); | |
return nvpair; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment