Files
kandev/apps/web/lib/gitlab-identity.ts
T
2026-07-21 23:24:22 +01:00

18 lines
572 B
TypeScript

export function normalizeGitLabOrigin(rawHost: string): string {
try {
const parsed = new URL(rawHost.includes("://") ? rawHost : `https://${rawHost}`);
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return "";
return `${parsed.protocol}//${parsed.host}`.toLowerCase();
} catch {
return "";
}
}
export function gitLabMRKey(host: string, projectPath: string, iid: number): string {
const path = projectPath
.trim()
.replace(/^\/+|\/+$/g, "")
.toLowerCase();
return `${normalizeGitLabOrigin(host)}|${path}!${iid}`;
}