Skip to content

Commit a294091

Browse files
committed
add test case to set cookies with special chars
1 parent 41d078d commit a294091

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/cookies/test/response-cookies.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,3 +262,16 @@ test('splitting multiple set-cookie', () => {
262262
expect(cookies2.get('foo')?.value).toBe(undefined)
263263
expect(cookies2.get('fooz')?.value).toBe('barz')
264264
})
265+
266+
test('cookie with special chars', () => {
267+
const headers = new Headers()
268+
const specialChars = 'bar 50%!@#$%^&*()_+'
269+
headers.set(
270+
'set-cookie',
271+
`foo=${JSON.stringify({ 'val': encodeURIComponent(specialChars) })}`,
272+
)
273+
const cookies = new ResponseCookies(headers)
274+
expect(cookies.getAll()).toEqual([
275+
{ name: 'foo', value: `{"val":"${specialChars}"}` },
276+
])
277+
})

0 commit comments

Comments
 (0)