Code coverage report for queryString/decode.js

Statements: 100% (10 / 10)      Branches: 83.33% (5 / 6)      Functions: 100% (3 / 3)      Lines: 100% (9 / 9)     

All files » queryString/ » decode.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 211         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;
});