diff --git a/.changeset/plenty-oranges-count.md b/.changeset/plenty-oranges-count.md new file mode 100644 index 000000000000..3031d3cc6f43 --- /dev/null +++ b/.changeset/plenty-oranges-count.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: do not override default cookie decoder to allow users to override the `cookie` library version diff --git a/packages/kit/src/runtime/server/cookie.js b/packages/kit/src/runtime/server/cookie.js index ddefa847a432..f4442872fbeb 100644 --- a/packages/kit/src/runtime/server/cookie.js +++ b/packages/kit/src/runtime/server/cookie.js @@ -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`, @@ -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 (