mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-26 02:41:16 +00:00
* refactor: remove gateway and channel dead exports * style: format config reload test * refactor: remove newly dead gateway exports * test: preserve approval audience coverage * refactor: preserve gateway contracts while pruning exports * test: retain gateway regression coverage * test: restore gateway policy coverage * test: close dead-export CI gaps * fix: reconcile dead exports with latest main * refactor: remove newly dead gateway runner export * test: remove private worker verifier coverage * test: preserve weak secret docs coverage * fix: avoid gateway health import cycle * fix: preserve node pairing type contract * style: format talk relay test * fix: preserve gateway protocol generation contract * chore: refresh dead export baseline * fix: preserve loaded target compatibility exports * fix: preserve plugin SDK declaration resolution * chore: refresh dead export baseline * chore: refresh dead export baseline * test(gateway): derive private worker service options
29 lines
905 B
TypeScript
29 lines
905 B
TypeScript
/** Parse a GitHub remote in HTTPS, SSH URL, or scp-like form. */
|
|
export function parseGitHubRemoteUrl(raw: string): { owner: string; repo: string } | null {
|
|
const trimmed = raw.trim();
|
|
let path: string | undefined;
|
|
const scpMatch = /^git@github\.com:(.+)$/i.exec(trimmed);
|
|
if (scpMatch) {
|
|
path = scpMatch[1];
|
|
} else {
|
|
try {
|
|
const url = new URL(trimmed);
|
|
const protocolOk =
|
|
url.protocol === "https:" || url.protocol === "http:" || url.protocol === "ssh:";
|
|
if (!protocolOk || url.hostname.toLowerCase() !== "github.com") {
|
|
return null;
|
|
}
|
|
path = url.pathname;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
const segments = (path ?? "").split("/").filter(Boolean);
|
|
const owner = segments[0];
|
|
const repo = segments[1]?.replace(/\.git$/i, "");
|
|
if (segments.length !== 2 || !owner || !repo) {
|
|
return null;
|
|
}
|
|
return { owner, repo };
|
|
}
|