/** * 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}`; }