/** * Prefixes for routes that must NOT get a dedicated-root rewrite (user jumped to * another vertical, API, or global page). Kept in sync with app routes and onion layout. */ import { DEDICATED_ROOT } from "@/lib/onionRoutes.generated"; const EXTRA_PREFIXES = [ "/api", "/hidden-wiki", "/launch", /** Stall pages: DEDICATED has `/vendors` but not vendor slug paths */ "/vendor", ] as const; const ONION_CROSS_NAV_PREFIXES: readonly string[] = (() => { const set = new Set([...Object.values(DEDICATED_ROOT), ...EXTRA_PREFIXES] as string[]); return Object.freeze(Array.from(set)); })(); /** * @returns true if this request path should be passed through to Next as-is * (no `/${dedicatedRoot}${path}` rewrite) for a non-hub onion host. */ export function isOnionCrossNavPath(pathname: string): boolean { if (pathname === "/w" || pathname.startsWith("/w/")) { return true; } for (const prefix of ONION_CROSS_NAV_PREFIXES) { if (pathname === prefix || pathname.startsWith(`${prefix}/`)) { return true; } } return false; }