Skip to content

Commit

Permalink
Fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
tacheometry committed May 18, 2024
1 parent 31b333e commit 38e3e24
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
12 changes: 6 additions & 6 deletions packages/router/__tests__/utils/custom-matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export function urlMatch(received, url) {
// => Resolved promise with status + headers
export function deferredData(received, done, status = 200, headers = {}) {
let deferredData = received as DeferredData;
let headersObject = deferredData.init!.headers
? new Headers(deferredData.init!.headers)
: new Headers();

return {
message: () =>
Expand All @@ -44,15 +47,12 @@ export function deferredData(received, done, status = 200, headers = {}) {
)}, ` +
`instead got done=${String(deferredData.done)}/status=${
deferredData.init!.status || 200
}/headers=${JSON.stringify(
Object.fromEntries(new Headers(deferredData.init!.headers ?? {}).entries())
)}`,
}/headers=${JSON.stringify(Object.fromEntries(headersObject.entries()))}`,
pass:
deferredData.done === done &&
(deferredData.init!.status || 200) === status &&
JSON.stringify(
Object.fromEntries(new Headers(deferredData.init!.headers ?? {}).entries())
) === JSON.stringify(headers),
JSON.stringify(Object.fromEntries(headersObject.entries())) ===
JSON.stringify(headers),
};
}

Expand Down
8 changes: 6 additions & 2 deletions packages/router/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,9 @@ export type JsonFunction = <Data>(
export const json: JsonFunction = (data, init = {}) => {
let responseInit = typeof init === "number" ? { status: init } : init;

let headers = new Headers(responseInit.headers ?? {});
let headers = responseInit.headers
? new Headers(responseInit.headers)
: new Headers();
if (!headers.has("Content-Type")) {
headers.set("Content-Type", "application/json; charset=utf-8");
}
Expand Down Expand Up @@ -1556,7 +1558,9 @@ export const redirect: RedirectFunction = (url, init = 302) => {
responseInit.status = 302;
}

let headers = new Headers(responseInit.headers ?? {});
let headers = responseInit.headers
? new Headers(responseInit.headers)
: new Headers();
headers.set("Location", url);

return new Response(null, {
Expand Down

0 comments on commit 38e3e24

Please sign in to comment.