public/javascripts/yui/cookie/cookie.js
function (text /*:String*/, decode /*:Boolean*/) /*:Object*/ {
        
        var cookies /*:Object*/ = {};
        
        if (YAHOO.lang.isString(text) && text.length > 0) {
            
            var decodeValue = (decode === false ? function(s){return s;} : decodeURIComponent);
            
            //if (/[^=]+=[^=;]?(?:; [^=]+=[^=]?)?/.test(text)){
                var cookieParts /*:Array*/ = text.split(/;\s/g),
                    cookieName /*:String*/ = null,
                    cookieValue /*:String*/ = null,
                    cookieNameValue /*:Array*/ = null;
                
                for (var i=0, len=cookieParts.length; i < len; i++){
                    
                    //check for normally-formatted cookie (name-value)
                    cookieNameValue = cookieParts[i].match(/([^=]+)=/i);
                    if (cookieNameValue instanceof Array){
                        try {
                            cookieName = decodeURIComponent(cookieNameValue[1]);
                            cookieValue = decodeValue(cookieParts[i].substring(cookieNameValue[1].length+1));
                        } catch (ex){
                            //ignore the entire cookie - encoding is likely invalid
                        }
                    } else {
                        //means the cookie does not have an "=", so treat it as a boolean flag
                        cookieName = decodeURIComponent(cookieParts[i]);
                        cookieValue = "";
                    }
                    cookies[cookieName] = cookieValue;
                }
            //}
        }
        
        return cookies;
    }
function (text /*:String*/, decode /*:Boolean*/) /*:Object*/ {
        
        var cookies /*:Object*/ = {};
        
        if (YAHOO.lang.isString(text) && text.length > 0) {
            
            var decodeValue = (decode === false ? function(s){return s;} : decodeURIComponent);
            
            //if (/[^=]+=[^=;]?(?:; [^=]+=[^=]?)?/.test(text)){
                var cookieParts /*:Array*/ = text.split(/;\s/g),
                    cookieName /*:String*/ = null,
                    cookieValue /*:String*/ = null,
                    cookieNameValue /*:Array*/ = null;
                
                for (var i=0, len=cookieParts.length; i < len; i++){
                    
                    //check for normally-formatted cookie (name-value)
                    cookieNameValue = cookieParts[i].match(/([^=]+)=/i);
                    if (cookieNameValue instanceof Array){
                        try {
                            cookieName = decodeURIComponent(cookieNameValue[1]);
                            cookieValue = decodeValue(cookieParts[i].substring(cookieNameValue[1].length+1));
                        } catch (ex){
                            //ignore the entire cookie - encoding is likely invalid
                        }
                    } else {
                        //means the cookie does not have an "=", so treat it as a boolean flag
                        cookieName = decodeURIComponent(cookieParts[i]);
                        cookieValue = "";
                    }
                    cookies[cookieName] = cookieValue;
                }
            //}
        }
        
        return cookies;
    }
function ( text /*:String*/ , decode /*:Boolean*/ ) /*:Object*/ { var cookies /*:Object*/ = { } ; if ( YAHOO . lang . isString ( text ) && text . length > 0 ) { var decodeValue = ( decode === false ? function ( s ) { return s ; } : decodeURIComponent ) ; //if (/[^=]+=[^=;]?(?:; [^=]+=[^=]?)?/.test(text)){ var cookieParts /*:Array*/ = text . split ( / ;\s / g ) , cookieName /*:String*/ = null , cookieValue /*:String*/ = null , cookieNameValue /*:Array*/ = null ; for ( var i = 0 , len = cookieParts . length ; i < len ; i ++ ) { //check for normally-formatted cookie (name-value) cookieNameValue = cookieParts [ i ] . match ( / ([^=]+)= / i ) ; if ( cookieNameValue instanceof Array ) { try { cookieName = decodeURIComponent ( cookieNameValue [ 1 ] ) ; cookieValue = decodeValue ( cookieParts [ i ] . substring ( cookieNameValue [ 1 ] . length + 1 ) ) ; } catch ( ex ) { //ignore the entire cookie - encoding is likely invalid } } else { //means the cookie does not have an "=", so treat it as a boolean flag cookieName = decodeURIComponent ( cookieParts [ i ] ) ; cookieValue = "" ; } cookies [ cookieName ] = cookieValue ; } //} } return cookies ; }
Parses a cookie string into an object representing all accessible cookies.
@param {String} text The cookie string to parse.
@param {Boolean} decode (Optional) Indicates if the cookie values should be decoded or not. Default is true.
@return {Object} An object containing entries for each accessible cookie.
@method _parseCookieString
@private
@static
Parses a cookie string into an object representing all accessible cookies .