Skip to content

Commit

Permalink
fix: use default cookie decoder (#13037)
Browse files Browse the repository at this point in the history
Co-authored-by: Simon H <[email protected]>
Co-authored-by: Ben McCann <[email protected]>
  • Loading branch information
3 people authored Nov 21, 2024
1 parent 239fe18 commit 1358ccc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/plenty-oranges-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: do not override default cookie decoder to allow users to override the `cookie` library version
6 changes: 2 additions & 4 deletions packages/kit/src/runtime/server/cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ export function get_cookies(request, url, trailing_slash) {
return c.value;
}

const decoder = opts?.decode || decodeURIComponent;
const req_cookies = parse(header, { decode: decoder });
const req_cookies = parse(header, { decode: opts?.decode });
const cookie = req_cookies[name]; // the decoded string or undefined

// in development, if the cookie was set during this session with `cookies.set`,
Expand All @@ -95,8 +94,7 @@ export function get_cookies(request, url, trailing_slash) {
* @param {import('cookie').CookieParseOptions} opts
*/
getAll(opts) {
const decoder = opts?.decode || decodeURIComponent;
const cookies = parse(header, { decode: decoder });
const cookies = parse(header, { decode: opts?.decode });

for (const c of Object.values(new_cookies)) {
if (
Expand Down

0 comments on commit 1358ccc

Please sign in to comment.