MCPcopy Create free account
hub / github.com/Snapchat/Valdi / parseGitHubRepoSlug

Function parseGitHubRepoSlug

npm_modules/cli/src/utils/githubUtils.ts:7–14  ·  view source on GitHub ↗

* Parses a GitHub repo URL (e.g. https://github.com/Snapchat/Valdi or .git variant) * into "owner/repo" for the GitHub API.

(repoUrl: string)

Source from the content-addressed store, hash-verified

5 * into "owner/repo" for the GitHub API.
6 */
7function parseGitHubRepoSlug(repoUrl: string): string {
8 const normalized = repoUrl.replace(/\.git$/u, '').trim();
9 const match = normalized.match(/github\.com[/:]([^/]+)\/([^/]+?)(?:[/]?$)/u);
10 if (!match) {
11 throw new Error(`Invalid GitHub URL: ${repoUrl}`);
12 }
13 return `${match[1]}/${match[2]}`;
14}
15
16const LATEST_RELEASE_HINT =
17 'Use --valdiVersion=latest to retry, or --valdiVersion=<tag> (e.g. main or v1.0.0) to pin a version.';

Callers 1

getLatestReleaseTagFunction · 0.85

Calls 3

replaceMethod · 0.65
trimMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected