Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
unreleased
==========

* Fix error passing `data` option to `Cookie` constructor

1.16.0 / 2019-04-10
===================

Expand Down
4 changes: 3 additions & 1 deletion session/cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ var Cookie = module.exports = function Cookie(options) {
}

for (var key in options) {
this[key] = options[key]
if (key !== 'data') {
this[key] = options[key]
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions test/cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ describe('new Cookie()', function () {
assert.throws(function () { new Cookie(function () {}) }, /argument options/)
})

it('should ignore "data" option', function () {
var cookie = new Cookie({ data: { foo: 'bar' }, path: '/foo' })

assert.strictEqual(typeof cookie, 'object')
assert.strictEqual(typeof cookie.data, 'object')
assert.strictEqual(cookie.data.path, '/foo')
assert.notStrictEqual(cookie.data.foo, 'bar')
})

describe('expires', function () {
it('should set expires', function () {
var expires = new Date(Date.now() + 60000)
Expand Down