Skip to content
Closed
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
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ function formatOpts(opts) {
if (!('maxAge' in opts)) opts.maxAge = opts.maxage;

// defaults
if (opts.overwrite == null) opts.overwrite = true;
if (opts.httpOnly == null) opts.httpOnly = true;
if (util.isNil(opts.overwrite)) opts.overwrite = true;
if (util.isNil(opts.httpOnly)) opts.httpOnly = true;
// delete null sameSite config
if (opts.sameSite == null) delete opts.sameSite;
if (opts.signed == null) opts.signed = true;
if (opts.autoCommit == null) opts.autoCommit = true;
if (util.isNil(opts.sameSite)) delete opts.sameSite;
if (util.isNil(opts.signed)) opts.signed = true;
if (util.isNil(opts.autoCommit)) opts.autoCommit = true;

debug('session options %j', opts);

Expand Down
4 changes: 4 additions & 0 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,9 @@ module.exports = {
return crc(JSON.stringify(sess));
},

isNil(val) {
return val === null || typeof val === 'undefined';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This modification is a little bit over abstract. I'd like to maintain the original style. :(

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

},

CookieDateEpoch: 'Thu, 01 Jan 1970 00:00:00 GMT',
};