decode.js
/**
 * Decode the URI Component encoded query string to object
 *
 * @param {string} The URI Component encoded query string
 * @returns {Object.<string, string>} Returns the decoded object
 */
Decode the URI Component encoded query string to object
@param {string} The URI Component encoded query string
@returns {Object.} Returns the decoded object
Decode the URI Component encoded query string to object @param { string } The URI Component encoded query string @returns { Object . } Returns the decoded object
function decode(string) {
    var object = {};
    var cache = {};
    var keyValueArray;
    var index;
    var length;
    var keyValue;
    var key;
    var value;
    if (string && typeof string === 'string') {
        keyValueArray = string.split('&');
        index = 0;
        length = keyValueArray.length;
        while (index < length) {
            keyValue = keyValueArray[index].split('=');
            key = decodeURIComponent(keyValue[0]);
            value = keyValue[1];
            if (typeof value === 'string') {
                value = decodeURIComponent(value);
            } else {
                value = null;
            }
            decodeKey(object, cache, key, value);
            index += 1;
        }
    }
    return object;
}
function decode ( string ) { var object = { } ; var cache = { } ; var keyValueArray ; var index ; var length ; var keyValue ; var key ; var value ; if ( string && typeof string === 'string' ) { keyValueArray = string . split ( '&' ) ; index = 0 ; length = keyValueArray . length ; while ( index < length ) { keyValue = keyValueArray [ index ] . split ( '=' ) ; key = decodeURIComponent ( keyValue [ 0 ] ) ; value = keyValue [ 1 ] ; if ( typeof value === 'string' ) { value = decodeURIComponent ( value ) ; } else { value = null ; } decodeKey ( object , cache , key , value ) ; index += 1 ; } } return object ; }
Decode the URI Component encoded query string to object
 @param {string} The URI Component encoded query string
 @returns {Object.<string, string>} Returns the decoded object
Decode the URI Component encoded query string to object @param { string } The URI Component encoded query string @returns { Object . <string string > } Returns the decoded object
// do not decode empty string or something that is not string