Skip to content
Myr

fix(client): serialize multiple cookies correctly (#5202)

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

authored by Ersa Oktavian Ramadan · committed by GitHub · parent 8a5852d · Browse files · 2 files+5 added−5 removed
This commit

State

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

Diff stats

2 files+5 added−5 removed

  • tests:+3 added−3 removed
  • other:+2 added−2 removed

2 files+5 added−5 removed

modified:src/client/client.test.ts+3 added-3 removed
272 unmodified lines
273 '/cookie',274 validator('cookie', () => {275 return {276 hello: 'world',277 goodbye: 'moon',278 }279 }),280 (c) => {281 const data = c.req.valid('cookie')
30 unmodified lines
312 const message = await request.headers.get('x-message-id')313 return HttpResponse.json({ 'x-message-id': message })314 }),315 http.get('http://localhost/api/cookie', async ({ request }) => {315 const obj = parse(request.headers.get('cookie') || '')316 const value = obj['hello']317 return HttpResponse.json({ hello: value })316 return HttpResponse.json(parse(request.headers.get('cookie') || ''))317 })318 )319320 beforeAll(() => server.listen())
50 unmodified lines
371372 it('Should get 200 response - cookie', async () => {373 const cookie = {374 hello: 'world',375 goodbye: 'moon',376 }377 const res = await client.cookie.$get({378 cookie,379 })
1625 unmodified lines
modified:src/client/client.ts+2 added-2 removed
96 unmodified lines
9798 if (args?.cookie) {99 const cookies: string[] = []100 for (const [key, value] of Object.entries(args.cookie)) {101 cookies.push(serialize(key, value, { path: '/' }))101 cookies.push(serialize(key, value))102 }103 headerValues['Cookie'] = cookies.join(',')103 headerValues['Cookie'] = cookies.join('; ')104 }105106 if (this.cType) {107 headerValues['Content-Type'] = this.cType
125 unmodified lines