mirror of
https://git.zhongyuan.online/ytke/tap.git
synced 2026-11-24 22:15:18 -08:00
10 lines
552 B
TypeScript
10 lines
552 B
TypeScript
/** Build-time public prefix. Keep in sync with Next.js `basePath`. */
|
|
export const basePath = process.env.NEXT_PUBLIC_BASE_PATH || '';
|
|
|
|
/** Prefix browser-native app URLs; Next.js Link/router/redirect already do this. */
|
|
export function appPath(path: string): string {
|
|
if (!basePath || !path.startsWith('/') || path.startsWith('//') || path.startsWith('/\\')) return path;
|
|
if (path === basePath || path.startsWith(`${basePath}/`) || path.startsWith(`${basePath}?`) || path.startsWith(`${basePath}#`)) return path;
|
|
return `${basePath}${path}`;
|
|
}
|