Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 10x 10x 2x 8x 8x 8x | /**
* Returns the base path configured for GitHub Pages project deployments.
*/
export function getBasePath(): string {
const rawBasePath = process.env.NEXT_PUBLIC_BASE_PATH?.trim() ?? "";
if (rawBasePath.length === 0 || rawBasePath === "/") {
return "";
}
return `/${rawBasePath.replace(/^\/+|\/+$/g, "")}`;
}
/**
* Prefixes internal public paths with the optional Next.js base path.
*
* This is used for static assets and generated report links that are not
* resolved through Next.js route helpers.
*/
export function withBasePath(path: string): string {
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
return `${getBasePath()}${normalizedPath}`;
}
|