From a294091a70512190f2806db4e8c4498899eed1f0 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Sun, 29 Sep 2024 16:32:43 +0530 Subject: [PATCH] add test case to set cookies with special chars --- packages/cookies/test/response-cookies.test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/cookies/test/response-cookies.test.ts b/packages/cookies/test/response-cookies.test.ts index 8c341bdd..9bc47d93 100644 --- a/packages/cookies/test/response-cookies.test.ts +++ b/packages/cookies/test/response-cookies.test.ts @@ -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}"}` }, + ]) +})