Skip to content
Open
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
4 changes: 0 additions & 4 deletions packages/cookies/src/response-cookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ function replace(bag: Map<string, ResponseCookie>, headers: Headers) {
}

function normalizeCookie(cookie: ResponseCookie = { name: '', value: '' }) {
if (typeof cookie.expires === 'number') {
cookie.expires = new Date(cookie.expires)
}

if (cookie.maxAge) {
cookie.expires = new Date(Date.now() + cookie.maxAge * 1000)
}
Expand Down
4 changes: 2 additions & 2 deletions packages/cookies/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export interface CookieListItem
name: string
/** A string containing the value of the cookie. */
value: string
/** A number of milliseconds or Date interface containing the expires of the cookie. */
expires?: number | CookieSerializeOptions['expires']
/** A Date interface containing the expires of the cookie. */
expires?: CookieSerializeOptions['expires']
}

/**
Expand Down
9 changes: 0 additions & 9 deletions packages/cookies/test/response-cookies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ test('reflect .set into `set-cookie`', async () => {
.set('foo', 'bar', { path: '/test' })
.set('fooz', 'barz', { path: '/test2' })
.set('fooHttpOnly', 'barHttpOnly', { httpOnly: true })
.set('fooExpires', 'barExpires', { expires: 0 })
.set('fooExpiresDate', 'barExpiresDate', { expires: new Date(0) })
.set('fooMaxAge', '', { maxAge: 0 })
.set('fooSameSite', 'barSameSite', {
Expand All @@ -24,7 +23,6 @@ test('reflect .set into `set-cookie`', async () => {
expect(cookies.get('foo')?.value).toBe('bar')
expect(cookies.get('fooz')?.value).toBe('barz')
expect(cookies.get('fooHttpOnly')?.value).toBe('barHttpOnly')
expect(cookies.get('fooExpires')?.value).toBe('barExpires')
expect(cookies.get('fooExpiresDate')?.value).toBe('barExpiresDate')
expect(cookies.get('fooMaxAge')?.value).toBe('')
expect(cookies.get('fooSameSite')?.value).toBe('barSameSite')
Expand All @@ -46,12 +44,6 @@ test('reflect .set into `set-cookie`', async () => {
path: '/',
httpOnly: true,
})
expect(cookies.get('fooExpires')).toEqual({
name: 'fooExpires',
value: 'barExpires',
path: '/',
expires: new Date(0),
})
expect(cookies.get('fooExpiresDate')).toEqual({
name: 'fooExpiresDate',
value: 'barExpiresDate',
Expand All @@ -77,7 +69,6 @@ test('reflect .set into `set-cookie`', async () => {
'foo=bar; Path=/test',
'fooz=barz; Path=/test2',
'fooHttpOnly=barHttpOnly; Path=/; HttpOnly',
'fooExpires=barExpires; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT',
'fooExpiresDate=barExpiresDate; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT',
'fooMaxAge=; Path=/; Max-Age=0',
'fooSameSite=barSameSite; Path=/; Secure; SameSite=none; Partitioned',
Expand Down