Skip to content

Commit

Permalink
Fix error passing "data" option to Cookie constructor
Browse files Browse the repository at this point in the history
fixes #648
closes #649
  • Loading branch information
eoL95 authored and dougwilson committed Apr 11, 2019
1 parent b1f0984 commit 1e3fc39
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions HISTORY.md
@@ -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
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
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

0 comments on commit 1e3fc39

Please sign in to comment.