singularity-forge/web/lib/project-url.ts
2026-05-05 14:31:16 +02:00

14 lines
408 B
TypeScript

export function buildProjectPath(path: string, projectCwd?: string): string {
if (!projectCwd) return path;
const url = new URL(path, "http://localhost");
url.searchParams.set("project", projectCwd);
return url.pathname + url.search;
}
export function buildProjectAbsoluteUrl(
path: string,
origin: string,
projectCwd?: string,
): URL {
return new URL(buildProjectPath(path, projectCwd), origin);
}