From b95243bc3c0183b153c75ec8fc1225a1aa4618dd Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Sun, 27 Oct 2024 07:58:04 -0400 Subject: [PATCH] fix(client): fix incorrectly specified redirects in router (#1809) --- client/src/router.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/client/src/router.ts b/client/src/router.ts index 8822f233d..36bc09b1b 100644 --- a/client/src/router.ts +++ b/client/src/router.ts @@ -1,4 +1,9 @@ -import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router"; +import { + createRouter, + createWebHistory, + type RouteRecordRaw, + type RouteLocation, +} from "vue-router"; import { isOfficialSite } from "./util/misc"; export const routes: RouteRecordRaw[] = [ @@ -24,11 +29,11 @@ export const routes: RouteRecordRaw[] = [ }, { path: "/r/:roomId", - redirect: "/room/:roomId", + redirect: redirectToRoom, }, { path: "/rooms/:roomId", - redirect: "/room/:roomId", + redirect: redirectToRoom, }, { path: "/passwordreset", @@ -41,6 +46,10 @@ export const routes: RouteRecordRaw[] = [ }, ]; +function redirectToRoom(to: RouteLocation) { + return { name: "room", params: { roomId: to.params.roomId } }; +} + // FIXME: only render on official site if (import.meta.env.DEV || isOfficialSite()) { routes.push({