* Parses a GitHub repo URL (e.g. https://github.com/Snapchat/Valdi or .git variant) * into "owner/repo" for the GitHub API.
(repoUrl: string)
| 5 | * into "owner/repo" for the GitHub API. |
| 6 | */ |
| 7 | function 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 | |
| 16 | const LATEST_RELEASE_HINT = |
| 17 | 'Use --valdiVersion=latest to retry, or --valdiVersion=<tag> (e.g. main or v1.0.0) to pin a version.'; |
no test coverage detected