nomadro/app/vip/lib/vipPath.ts
eric 9f8fec1723 Ship portal PC/H5 acceptance, VIP ScrollReader, admin analytics and ops anchors.
Adds /api/health, ntfy notify on config save, /admin/analytics charts, and deploy smoke for miniprogram config/API.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-28 23:52:00 -05:00

26 lines
832 B
TypeScript

/**
* Portal mount prefix for VIP routes.
* Standalone vip.hackrobot.cn: set NEXT_PUBLIC_VIP_BASE_PATH="" (or unset → treated as "").
* Nomadro portal: NEXT_PUBLIC_VIP_BASE_PATH=/vip (default in monorepo).
*/
const RAW =
typeof process !== "undefined"
? process.env.NEXT_PUBLIC_VIP_BASE_PATH
: undefined;
/** Empty string = site root; monorepo portal defaults to /vip */
export const VIP_BASE =
RAW === undefined || RAW === null
? "/vip"
: RAW.replace(/\/$/, "");
export function vipPath(path: string): string {
if (!path || path.startsWith("http") || path.startsWith("#") || path.startsWith("mailto:")) {
return path;
}
const p = path.startsWith("/") ? path : `/${path}`;
if (!VIP_BASE) return p;
if (p === VIP_BASE || p.startsWith(`${VIP_BASE}/`)) return p;
return `${VIP_BASE}${p}`;
}