Skip to content

Commit

Permalink
Redirect to 404 for all invalid paths
Browse files Browse the repository at this point in the history
  • Loading branch information
lemonyte committed Dec 21, 2024
1 parent a2445e2 commit 16d5324
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/routes/[code]/+page.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { redirect } from "@sveltejs/kit";
import type { PageLoad } from "./$types";
import { STATUS_CODES } from "$lib/codes";

export const load: PageLoad = ({ params }) => {
const code = parseInt(params.code);
if (code in STATUS_CODES) {
return {
code,
};
return { code };
}

return {
code: 404,
};
redirect(307, "/404");
};
6 changes: 6 additions & 0 deletions src/routes/[code]/[...path]/+page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { redirect } from "@sveltejs/kit";
import type { PageLoad } from "./$types";

export const load: PageLoad = async (_) => {
redirect(307, "/404");
};

0 comments on commit 16d5324

Please sign in to comment.