Skip to content
Myr

fix: error to retrieve cookie (#1386)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* fix: error to retrieve cookie TypeError: Cannot read properties of undefined (reading 'split') * add a test and denoify ---------

authored by uaichat · committed by GitHub · parent c865b50 · Browse files · 3 files+21 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Yusuke Wada <yusuke@cloudflare.com>

Diff stats

3 files+21 added−2 removed

  • tests:+19 added−0 removed
  • other:+2 added−2 removed

3 files+21 added−2 removed

modified:deno_dist/helper/cookie/index.ts+1 added-1 removed
modified:src/helper/cookie/index.test.ts+19 added
113 unmodified lines
114 req.headers.set('Cookie', cookieString)115 const res = await app.request(req)116 expect(res.headers.get('Fortune-Cookie')).toBe('INVALID')117 })118119 describe('get null if the value is undefined', () => {120 const app = new Hono()121122 app.get('/cookie', (c) => {123 const yummyCookie = getCookie(c, 'yummy_cookie')124 const res = new Response('Good cookie')125 if (yummyCookie) res.headers.set('Yummy-Cookie', yummyCookie)126 return res127 })128129 it('Should be null', async () => {130 const req = new Request('http://localhost/cookie')131 const cookieString = 'yummy_cookie='132 req.headers.set('Cookie', cookieString)133 const res = await app.request(req)134 expect(res.headers.get('Yummy-Cookie')).toBe(null)135 })136 })137 })138139 describe('Set cookie', () => {140 const app = new Hono()
130 unmodified lines
modified:src/helper/cookie/index.ts+1 added-1 removed