dont fail on empty qstring

This commit is contained in:
Sanj 2011-10-03 08:23:38 +05:30
parent 47be3093ae
commit 30f4dedde4

View File

@ -216,9 +216,12 @@ function JSONtoQueryString(obj) {
{'var1': 'bar', 'var2': 'baz'}
*/
function QueryStringToJSON(qstring) {
var qstring = qstring.split("?")[1];
if (qstring.indexOf("?") == -1) {
return {};
}
var q = qstring.split("?")[1];
var args = {};
var vars = qstring.split('&');
var vars = q.split('&');
// console.log(vars);
for (var i=0; i<vars.length; i++) {
var kv = vars[i].split('=');