@edge-runtime/cookies
Advanced tools
Comparing version 3.0.5 to 3.0.6
@@ -117,3 +117,3 @@ // Type definitions for cookie 0.5 | ||
*/ | ||
interface CookieListItem extends Pick<CookieSerializeOptions, 'domain' | 'path' | 'expires' | 'secure' | 'sameSite'> { | ||
interface CookieListItem extends Pick<CookieSerializeOptions, 'domain' | 'path' | 'secure' | 'sameSite'> { | ||
/** A string with the name of a cookie. */ | ||
@@ -123,2 +123,4 @@ name: string; | ||
value: string; | ||
/** A number of milliseconds or Date interface containing the expires of the cookie. */ | ||
expires?: number | CookieSerializeOptions['expires']; | ||
} | ||
@@ -125,0 +127,0 @@ /** |
@@ -32,3 +32,3 @@ "use strict"; | ||
"path" in c && c.path && `Path=${c.path}`, | ||
"expires" in c && c.expires && `Expires=${c.expires.toUTCString()}`, | ||
"expires" in c && (c.expires || c.expires === 0) && `Expires=${(typeof c.expires === "number" ? new Date(c.expires) : c.expires).toUTCString()}`, | ||
"maxAge" in c && c.maxAge && `Max-Age=${c.maxAge}`, | ||
@@ -211,2 +211,5 @@ "domain" in c && c.domain && `Domain=${c.domain}`, | ||
function normalizeCookie(cookie = { name: "", value: "" }) { | ||
if (typeof cookie.expires === "number") { | ||
cookie.expires = new Date(cookie.expires); | ||
} | ||
if (cookie.maxAge) { | ||
@@ -213,0 +216,0 @@ cookie.expires = new Date(Date.now() + cookie.maxAge * 1e3); |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://edge-runtime.vercel.app/packages/cookies", | ||
"version": "3.0.5", | ||
"version": "3.0.6", | ||
"main": "dist/index.js", | ||
@@ -8,0 +8,0 @@ "module": "dist/index.mjs", |
Sorry, the diff of this file is not supported yet
43139
699