From c3e98d8303190d415db5cf06f8a02e3fce964840 Mon Sep 17 00:00:00 2001 From: aristofun Date: Tue, 8 Oct 2024 22:39:00 -0400 Subject: [PATCH] fastifyCookieClearCookie sets maxAge to zero --- package.json | 2 +- plugin.js | 2 +- test/cookie.test.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index fc94f74..ce9ae8c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/plugin.js b/plugin.js index 8aec1ca..2ff9e66 100644 --- a/plugin.js +++ b/plugin.js @@ -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) diff --git a/test/cookie.test.js b/test/cookie.test.js index 7f277f1..77e1c22 100644 --- a/test/cookie.test.js +++ b/test/cookie.test.js @@ -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()) }) @@ -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')