Fixing cookie specs
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by visionmedia · committed by visionmedia · parent e7ad5fa · Browse files · 2 files·+21 added−25 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+21 added−25 removed
- tests:+20 added−24 removed
- other:+1 added−1 removed
Provenance
- Commit
48bea03- Tree
2207312- Author
visionmedia <tj@vision-media.ca>- Committer
visionmedia <tj@vision-media.ca>- Parent
e7ad5fa
2 files changed+21 added−25 removed
modified:lib/express/plugins/cookie.js+1 added-1 removed
32 unmodified lines3334353637373839404135 unmodified lines32 unmodified lines val = val.toString() .replace(/^(\w+)/, '$1,') .replace(/(\w+) (\d+) (\d+)/, '$2-$1-$3') .replace(/GMT.*$/, 'GMT') return key + '=' + val return val === true ? key : key + '=' + val }).toArray().join('; ')}
// --- Request35 unmodified linesmodified:spec/spec.plugins.cookie.js+20 added-24 removed
17 unmodified lines18192021222223242524262728293031323334353637383940303132333435364142434445404142434445464647484949505152535455565051525354555639 unmodified lines17 unmodified lines end it 'should currectly format any Date objects' var data = { expires: new Date('May 25, 1987 11:13:00') expires: new Date('May 25, 1987 11:13:00'), path: '/foo', domain: '.vision-media.ca' } compileCookie(data).should.eql 'expires=Mon, 25-May-1987 11:13:00 GMT' compileCookie(data).should.eql 'expires=Mon, 25-May-1987 11:13:00 GMT; path=/foo; domain=.vision-media.ca' end it 'should convert true to a key without a value' var data = { path: '/', secure: true, httpOnly: true } compileCookie(data).should.eql 'path=/; secure; httpOnly' end end describe 'parseCookie()' it 'should parse cookie key/value pairs' var attrs = 'expires=Fri, 31-Dec-2010 23:59:59 GMT; path=/; domain=.example.net' var expected = { expires: 'Fri, 31-Dec-2010 23:59:59 GMT', path: '/', domain: '.example.net' } parseCookie(attrs).should.eql expected var attrs = 'sid=1232431234234; data=foo' parseCookie(attrs).should.eql { sid: '1232431234234', data: 'foo' } end it 'should normalize keys to lowercase' var attrs = 'Expires=Fri, 31-Dec-2010 23:59:59 GMT; Path=/; DOMAIN=.example.net' var expected = { expires: 'Fri, 31-Dec-2010 23:59:59 GMT', path: '/', domain: '.example.net' } parseCookie(attrs).should.eql expected var attrs = 'SID=1232431234234; data=foo' parseCookie(attrs).should.eql { sid: '1232431234234', data: 'foo' } end it 'should disregard ad-hoc whitespace' var attrs = ' expires = Fri, 31-Dec-2010 23:59:59 GMT ; path = /; domain = .example.net ' var expected = { expires: 'Fri, 31-Dec-2010 23:59:59 GMT', path: '/', domain: '.example.net' } parseCookie(attrs).should.eql expected it 'should disregard ad-hoc invalid whitespace' var attrs = ' SID = 1232431234234 ; data = foo' parseCookie(attrs).should.eql { sid: '1232431234234', data: 'foo' } end end describe 'on'39 unmodified lines