aboutsummaryrefslogtreecommitdiff
path: root/src/hooks.server.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/hooks.server.ts')
-rw-r--r--src/hooks.server.ts24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/hooks.server.ts b/src/hooks.server.ts
index 48fc1f1b..d0f09b6e 100644
--- a/src/hooks.server.ts
+++ b/src/hooks.server.ts
@@ -1,4 +1,19 @@
-import type { Handle } from '@sveltejs/kit';
+import root from '$lib/Utility/root';
+import type { Handle, RequestEvent } from '@sveltejs/kit';
+
+const redirectWithParameters = (
+ event: RequestEvent<Partial<Record<string, string>>, string | null>,
+ path: string
+) => {
+ return Response.redirect(
+ root(
+ `${path}${
+ event.url.searchParams.toString().length > 0 ? `?${event.url.searchParams.toString()}` : ''
+ }`
+ ),
+ 307
+ );
+};
export const handle: Handle = async ({ event, resolve }) => {
const { cookies } = event;
@@ -15,5 +30,12 @@ export const handle: Handle = async ({ event, resolve }) => {
};
}
+ switch (event.url.pathname) {
+ case '/birthdays':
+ return redirectWithParameters(event, '/tools/birthdays');
+ case '/wrapped':
+ return redirectWithParameters(event, '/tools/wrapped');
+ }
+
return await resolve(event);
};