Skip to content

Commit

Permalink
Merge pull request hapijs#265 from ldesplat/master
Browse files Browse the repository at this point in the history
Set isSameSite to false and add code to support Hapi 13.5+
  • Loading branch information
ldesplat authored Sep 21, 2016
2 parents bcd53e5 + 705e1d0 commit 4077318
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,27 @@ internals.implementation = function (server, options) {
password: settings.password,
isSecure: settings.isSecure !== false, // Defaults to true
isHttpOnly: settings.isHttpOnly !== false, // Defaults to true
isSameSite: false,
ttl: settings.ttl,
domain: settings.domain,
ignoreErrors: true,
clearInvalid: true
};

settings.cookie = settings.cookie || 'bell-' + settings.name;
server.state(settings.cookie, cookieOptions);
try {
server.state(settings.cookie, cookieOptions);
}
catch (exception) {
/* $lab:coverage:off$ */
// This is to support Hapi 13.5.0 so that adding isSameSite: false option is not a breaking change
if (exception.message.indexOf('isSameSite') === -1) {
throw exception;
}
delete cookieOptions.isSameSite;
server.state(settings.cookie, cookieOptions);
/* $lab:coverage:on$ */
}

if (internals.simulate) {
return internals.simulated(settings);
Expand Down

0 comments on commit 4077318

Please sign in to comment.