1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 1 1 5 5 19 19 19 5 1 | define(['../string/typecast', '../lang/isString'], function (typecast, isString) {
/**
* Decode query string into an object of keys => vals.
*/
function decode(queryStr, shouldTypecast) {
var queryArr = (queryStr || '').replace('?', '').split('&'),
n = queryArr.length,
obj = {},
item, val;
while (n--) {
item = queryArr[n].split('=');
val = shouldTypecast === false? item[1] : typecast(item[1]);
obj[item[0]] = isString(val)? decodeURIComponent(val) : val;
}
return obj;
}
return decode;
});
|