Skip to content

Commit

Permalink
add test case to set cookies with special chars
Browse files Browse the repository at this point in the history
  • Loading branch information
abhi12299 committed Sep 29, 2024
1 parent 41d078d commit a294091
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/cookies/test/response-cookies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,16 @@ test('splitting multiple set-cookie', () => {
expect(cookies2.get('foo')?.value).toBe(undefined)
expect(cookies2.get('fooz')?.value).toBe('barz')
})

test('cookie with special chars', () => {
const headers = new Headers()
const specialChars = 'bar 50%!@#$%^&*()_+'
headers.set(
'set-cookie',
`foo=${JSON.stringify({ 'val': encodeURIComponent(specialChars) })}`,
)
const cookies = new ResponseCookies(headers)
expect(cookies.getAll()).toEqual([
{ name: 'foo', value: `{"val":"${specialChars}"}` },
])
})

0 comments on commit a294091

Please sign in to comment.