middleware/cookie_parser/application.js
function parseCookie(str) {
  var obj = {},
    pairs = str.split(/[;,] */);

  for (var pair,eqlIndex,key,val,i=0; i < pairs.length; i++) {
    pair = pairs[i];
    eqlIndex = pair.indexOf('=');
    key = pair.substr(0, eqlIndex).trim().toLowerCase();
    val = pair.substr(++eqlIndex, pair.length).trim();
    if ('"' === val[0]) val = val.slice(1, -1);
    if (obj[key] === undefined) {
      val = val.replace(/\+/g, ' ');
      try {
        obj[key] = decodeURIComponent(val);
      } catch (err) {
        if (err instanceof URIError) {
          obj[key] = val;
        } else {
          throw err;
        }
      }
    }
  }
  return obj;
}
function parseCookie(str) {
  var obj = {},
    pairs = str.split(/[;,] */);

  for (var pair,eqlIndex,key,val,i=0; i < pairs.length; i++) {
    pair = pairs[i];
    eqlIndex = pair.indexOf('=');
    key = pair.substr(0, eqlIndex).trim().toLowerCase();
    val = pair.substr(++eqlIndex, pair.length).trim();
    if ('"' === val[0]) val = val.slice(1, -1);
    if (obj[key] === undefined) {
      val = val.replace(/\+/g, ' ');
      try {
        obj[key] = decodeURIComponent(val);
      } catch (err) {
        if (err instanceof URIError) {
          obj[key] = val;
        } else {
          throw err;
        }
      }
    }
  }
  return obj;
}
function parseCookie ( str ) { var obj = { } , pairs = str . split ( / [;,] * / ) ; for ( var pair , eqlIndex , key , val , i = 0 ; i < pairs . length ; i ++ ) { pair = pairs [ i ] ; eqlIndex = pair . indexOf ( '=' ) ; key = pair . substr ( 0 , eqlIndex ) . trim ( ) . toLowerCase ( ) ; val = pair . substr ( ++ eqlIndex , pair . length ) . trim ( ) ; if ( '"' === val [ 0 ] ) val = val . slice ( 1 , - 1 ) ; if ( obj [ key ] === undefined ) { val = val . replace ( / \+ / g , ' ' ) ; try { obj [ key ] = decodeURIComponent ( val ) ; } catch ( err ) { if ( err instanceof URIError ) { obj [ key ] = val ; } else { throw err ; } } } } return obj ; }
Parses the cookie header

@param {string} str
@returns {object}
@private
Parses the cookie header