refactor(routes): move shared pages to global scope
This commit is contained in:
@@ -7,7 +7,7 @@ export type RouteAccess =
|
||||
| "realUser"
|
||||
| "authOnly";
|
||||
|
||||
const STATIC_ROUTE_ACCESS: Partial<Record<string, RouteAccess>> = {
|
||||
const GLOBAL_ROUTE_ACCESS: Partial<Record<string, RouteAccess>> = {
|
||||
[ROUTES.root]: "public",
|
||||
[ROUTES.splash]: "authOnly",
|
||||
[ROUTES.auth]: "authOnly",
|
||||
@@ -26,14 +26,11 @@ const CHARACTER_ROUTE_ACCESS: Readonly<Record<string, RouteAccess>> = {
|
||||
chat: "guestEntry",
|
||||
"private-room": "guestEntry",
|
||||
tip: "public",
|
||||
sidebar: "session",
|
||||
feedback: "session",
|
||||
"coins-rules": "public",
|
||||
};
|
||||
|
||||
export function getRouteAccess(pathname: string): RouteAccess {
|
||||
const staticAccess = STATIC_ROUTE_ACCESS[pathname];
|
||||
if (staticAccess) return staticAccess;
|
||||
const globalAccess = GLOBAL_ROUTE_ACCESS[pathname];
|
||||
if (globalAccess) return globalAccess;
|
||||
|
||||
const match = pathname.match(/^\/characters\/[^/]+\/([^/]+)\/?$/);
|
||||
return (match?.[1] && CHARACTER_ROUTE_ACCESS[match[1]]) || "public";
|
||||
|
||||
Reference in New Issue
Block a user