Skip to content

Commit 1e3fc39

Browse files
eoL95dougwilson
authored andcommitted
Fix error passing "data" option to Cookie constructor
fixes #648 closes #649
1 parent b1f0984 commit 1e3fc39

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

HISTORY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
unreleased
2+
==========
3+
4+
* Fix error passing `data` option to `Cookie` constructor
5+
16
1.16.0 / 2019-04-10
27
===================
38

session/cookie.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ var Cookie = module.exports = function Cookie(options) {
3333
}
3434

3535
for (var key in options) {
36-
this[key] = options[key]
36+
if (key !== 'data') {
37+
this[key] = options[key]
38+
}
3739
}
3840
}
3941

test/cookie.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ describe('new Cookie()', function () {
4444
assert.throws(function () { new Cookie(function () {}) }, /argument options/)
4545
})
4646

47+
it('should ignore "data" option', function () {
48+
var cookie = new Cookie({ data: { foo: 'bar' }, path: '/foo' })
49+
50+
assert.strictEqual(typeof cookie, 'object')
51+
assert.strictEqual(typeof cookie.data, 'object')
52+
assert.strictEqual(cookie.data.path, '/foo')
53+
assert.notStrictEqual(cookie.data.foo, 'bar')
54+
})
55+
4756
describe('expires', function () {
4857
it('should set expires', function () {
4958
var expires = new Date(Date.now() + 60000)

0 commit comments

Comments
 (0)