Skip to content

Commit

Permalink
fix(client): fix incorrectly specified redirects in router (#1809)
Browse files Browse the repository at this point in the history
  • Loading branch information
dyc3 authored Oct 27, 2024
1 parent 1f33f52 commit b95243b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions client/src/router.ts
Original file line number Diff line number Diff line change
@@ -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[] = [
Expand All @@ -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",
Expand All @@ -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({
Expand Down

0 comments on commit b95243b

Please sign in to comment.