mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-02 22:43:27 +00:00
14 lines
492 B
TypeScript
14 lines
492 B
TypeScript
|
|
/** Normalize GitHub repo input to `owner/name`. */
|
||
|
|
export function normalizeRepoFullName(raw: string): string | null {
|
||
|
|
let v = raw.trim();
|
||
|
|
for (const prefix of ["https://github.com/", "http://github.com/", "github.com/"]) {
|
||
|
|
if (v.toLowerCase().startsWith(prefix)) {
|
||
|
|
v = v.slice(prefix.length);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
v = v.replace(/\/$/, "").replace(/\.git$/, "");
|
||
|
|
const parts = v.split("/").filter(Boolean);
|
||
|
|
if (parts.length !== 2) return null;
|
||
|
|
return `${parts[0]}/${parts[1]}`;
|
||
|
|
}
|