Skip to content

Commit

Permalink
Cookie expires now using Date#toGMTString()
Browse files Browse the repository at this point in the history
Spec I found wanted hyphens, but this appears to be the norm
for JS cookies
  • Loading branch information
tj committed Apr 7, 2010
1 parent 8ed24de commit a318ef2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions lib/express/plugins/cookie.js
Expand Up @@ -37,10 +37,7 @@ exports.compileCookie = function(name, val, options) {
if (!options) return name + '=' + val
return name + '=' + val + '; ' + options.map(function(val, key){
if (val instanceof Date)
val = val.toString()
.replace(/^(\w+)/, '$1,')
.replace(/(\w+) (\d+) (\d+)/, '$2-$1-$3')
.replace(/GMT.*$/, 'GMT')
val = val.toGMTString()
return val === true ? key : key + '=' + val
}).join('; ')
}
Expand Down
2 changes: 1 addition & 1 deletion spec/spec.plugins.cookie.js
Expand Up @@ -23,7 +23,7 @@ describe 'Express'
path: '/foo',
domain: '.vision-media.ca'
}
compileCookie('foo', 'bar', options).should.eql 'foo=bar; expires=Mon, 25-May-1987 11:13:00 GMT; path=/foo; domain=.vision-media.ca'
compileCookie('foo', 'bar', options).should.eql 'foo=bar; expires=Mon, 25 May 1987 18:13:00 GMT; path=/foo; domain=.vision-media.ca'
end

it 'should convert true to a key without a value'
Expand Down

0 comments on commit a318ef2

Please sign in to comment.