lib/collection/cookie.js
function (str) {
        if (!_.isString(str)) {
            return str;
        }

        var obj = {},
            pairs = str.split(PAIR_SPLIT_REGEX),
            nameval;

        nameval = Cookie.splitParam(pairs.shift()); // The first kvp is the name and value
        obj.key = nameval.key;
        obj.value = nameval.value;

        pairs.forEach(function (pair) {
            var keyval = Cookie.splitParam(pair),
                value = keyval.value,
                keyLower = keyval.key.toLowerCase();

            if (cookieAttributes[keyLower]) {
                obj[cookieAttributes[keyLower]] = value;
            }
            else {
                obj.extensions = obj.extensions || [];
                obj.extensions.push(keyval);
            }
        });
        // Handle the hostOnly flag
        if (!obj.domain) {
            obj.hostOnly = true;
        }
        return obj;
    }
function (str) {
        if (!_.isString(str)) {
            return str;
        }

        var obj = {},
            pairs = str.split(PAIR_SPLIT_REGEX),
            nameval;

        nameval = Cookie.splitParam(pairs.shift()); // The first kvp is the name and value
        obj.key = nameval.key;
        obj.value = nameval.value;

        pairs.forEach(function (pair) {
            var keyval = Cookie.splitParam(pair),
                value = keyval.value,
                keyLower = keyval.key.toLowerCase();

            if (cookieAttributes[keyLower]) {
                obj[cookieAttributes[keyLower]] = value;
            }
            else {
                obj.extensions = obj.extensions || [];
                obj.extensions.push(keyval);
            }
        });
        // Handle the hostOnly flag
        if (!obj.domain) {
            obj.hostOnly = true;
        }
        return obj;
    }
function ( str ) { if ( ! _ . isString ( str ) ) { return str ; } var obj = { } , pairs = str . split ( PAIR_SPLIT_REGEX ) , nameval ; nameval = Cookie . splitParam ( pairs . shift ( ) ) ; // The first kvp is the name and value obj . key = nameval . key ; obj . value = nameval . value ; pairs . forEach ( function ( pair ) { var keyval = Cookie . splitParam ( pair ) , value = keyval . value , keyLower = keyval . key . toLowerCase ( ) ; if ( cookieAttributes [ keyLower ] ) { obj [ cookieAttributes [ keyLower ] ] = value ; } else { obj . extensions = obj . extensions || [ ] ; obj . extensions . push ( keyval ) ; } } ) ; // Handle the hostOnly flag if ( ! obj . domain ) { obj . hostOnly = true ; } return obj ; }
Cookie header parser

@param {String} str
@returns {*} A plain cookie options object, use it to create a new Cookie
Cookie header parser