Skip to content

Commit

Permalink
fastifyCookieClearCookie sets maxAge to zero
Browse files Browse the repository at this point in the history
  • Loading branch information
aristofun committed Oct 9, 2024
1 parent f2aed09 commit c3e98d8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fastify/cookie",
"version": "10.0.1",
"version": "10.0.2",
"description": "Plugin for fastify to add support for cookies",
"main": "plugin.js",
"type": "commonjs",
Expand Down
2 changes: 1 addition & 1 deletion plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function fastifyCookieClearCookie (reply, name, options) {
const opts = Object.assign({ path: '/' }, options, {
expires: new Date(1),
signed: undefined,
maxAge: undefined
maxAge: 0
})

return fastifyCookieSetCookie(reply, name, '', opts)
Expand Down
4 changes: 2 additions & 2 deletions test/cookie.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ test('share options for setCookie and clearCookie', (t) => {
t.equal(cookies.length, 1)
t.equal(cookies[0].name, 'foo')
t.equal(cookies[0].value, '')
t.equal(cookies[0].maxAge, undefined)
t.equal(cookies[0].maxAge, 0)

t.ok(new Date(cookies[0].expires) < new Date())
})
Expand Down Expand Up @@ -1054,7 +1054,7 @@ test('clearCookie should include parseOptions', (t) => {
t.equal(cookies.length, 1)
t.equal(cookies[0].name, 'foo')
t.equal(cookies[0].value, '')
t.equal(cookies[0].maxAge, undefined)
t.equal(cookies[0].maxAge, 0)
t.equal(cookies[0].path, '/test')
t.equal(cookies[0].domain, 'example.com')

Expand Down

0 comments on commit c3e98d8

Please sign in to comment.