Skip to content

Commit

Permalink
clean up assertions where we are passing an explicit decode callback
Browse files Browse the repository at this point in the history
  • Loading branch information
Conduitry committed Jan 29, 2025
1 parent 4b35912 commit ef525b3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/kit/src/runtime/server/cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ function validate_options(options) {
*/
export function get_cookies(request, url, trailing_slash) {
const header = request.headers.get('cookie') ?? '';
const initial_cookies = parse(header, { decode: (value) => value });
const initial_cookies = /** @type {Record<string, string>} */ (
parse(header, { decode: (value) => value })
);

const normalized_url = normalize_path(url.pathname, trailing_slash);

Expand Down Expand Up @@ -151,7 +153,7 @@ export function get_cookies(request, url, trailing_slash) {
* @param {string | null} header
*/
function get_cookie_header(destination, header) {
/** @type {Record<string, string | undefined>} */
/** @type {Record<string, string>} */
const combined_cookies = {
// cookies sent by the user agent have lowest precedence
...initial_cookies
Expand All @@ -169,7 +171,9 @@ export function get_cookies(request, url, trailing_slash) {

// explicit header has highest precedence
if (header) {
const parsed = parse(header, { decode: (value) => value });
const parsed = /** @type {Record<string, string>} */ (
parse(header, { decode: (value) => value })
);
for (const name in parsed) {
combined_cookies[name] = parsed[name];
}
Expand Down

0 comments on commit ef525b3

Please sign in to comment.