Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use default cookie decoder instead of bare native #13037

Merged
merged 6 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
benmccann marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 4 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,8 @@ export function get_cookies(request, url, trailing_slash) {
return c.value;
}

const decoder = opts?.decode || decodeURIComponent;
const req_cookies = parse(header, { decode: decoder });
// `parse` uses default decoder if `opts.decode` is undefined
benmccann marked this conversation as resolved.
Show resolved Hide resolved
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 +95,8 @@ 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 });
// `parse` uses default decoder if `opts.decode` is undefined
benmccann marked this conversation as resolved.
Show resolved Hide resolved
const cookies = parse(header, { decode: opts?.decode });

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