Skip to content

Commit

Permalink
add slash
Browse files Browse the repository at this point in the history
  • Loading branch information
datkat21 committed Nov 9, 2023
1 parent 84ac9d8 commit 623d433
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion handlers/handling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,15 @@ export function fileOnlyReqHandler(
let urlPath = url.pathname.substring(prefix.length);

// default handlers built into the program
if (urlPath.endsWith("/") || urlPath === "") {
if (urlPath === "") {
// redirect to /
return new Response("Redirect", {
status: 301,
statusText: "Moved",
headers: { Location: prefix + "/" },
});
}
if (urlPath.endsWith("/")) {
urlPath = "/index.html";
}

Expand Down

0 comments on commit 623d433

Please sign in to comment.