Capture the current CyberLux UI, commerce, messaging, and Tor ops updates so local main can be pushed to the remote. Made-with: Cursor
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
/**
|
|
* 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<string>([...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;
|
|
}
|