handling no existingUrl scenario

This commit is contained in:
snkashis 2012-12-27 14:39:19 -05:00
parent 3d416f38e1
commit 6b4f5c4cf7
2 changed files with 8 additions and 1 deletions

View File

@ -80,6 +80,13 @@ describe('Util', function() {
expect(L.Util.getParamString(b.obj,b.url)).toEqual(b.result);
var c = {
url: undefined,
obj: {bar: 7, baz: 3},
result: "?bar=7&baz=3"
};
expect(L.Util.getParamString(c.obj,c.url)).toEqual(c.result);
});
});

View File

@ -84,7 +84,7 @@ L.Util = {
params.push(i + '=' + obj[i]);
}
}
return (existingUrl.indexOf('?') === -1 ? '?' : '&') + params.join('&');
return ((!existingUrl || existingUrl.indexOf('?') === -1) ? '?' : '&') + params.join('&');
},
template: function (str, data) {