File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ unreleased
2+ ==========
3+
4+ * Fix error passing ` data ` option to ` Cookie ` constructor
5+
161.16.0 / 2019-04-10
27===================
38
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -44,6 +44,15 @@ describe('new Cookie()', function () {
4444 assert . throws ( function ( ) { new Cookie ( function ( ) { } ) } , / a r g u m e n t o p t i o n s / )
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 )
You can’t perform that action at this time.
0 commit comments