Skip to content

Commit

Permalink
technically fixed, though types will have to catch up
Browse files Browse the repository at this point in the history
  • Loading branch information
tcc-sejohnson committed May 11, 2023
1 parent 1ad431c commit a9ae11b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 11 additions & 1 deletion packages/kit/src/runtime/server/cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,23 @@ export function get_cookies(request, url, trailing_slash) {
* @param {import('cookie').CookieSerializeOptions} opts
*/
set(name, value, opts = {}) {
return this.set_internal(name, value, { with_defaults: true, ...opts });
},

/**
* @param {string} name
* @param {string} value
* @param {import('cookie').CookieSerializeOptions & { with_defaults?: boolean }} opts
*/
set_internal(name, value, opts = {}) {
let path = opts.path ?? default_path;
const with_defaults = opts.with_defaults ?? true;

new_cookies[name] = {
name,
value,
options: {
...defaults,
...(with_defaults ? defaults : {}),
...opts,
path
}
Expand Down
9 changes: 4 additions & 5 deletions packages/kit/src/runtime/server/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,10 @@ export function create_fetch({ event, options, manifest, state, get_cookie_heade
const { name, value, ...options } = set_cookie_parser.parseString(str);

// options.sameSite is string, something more specific is required - type cast is safe
event.cookies.set(
name,
value,
/** @type {import('cookie').CookieSerializeOptions} */ (options)
);
event.cookies.set_internal(name, value, {
with_defaults: false,
.../** @type {import('cookie').CookieSerializeOptions} */ (options)
});
}
}

Expand Down

0 comments on commit a9ae11b

Please sign in to comment.