support giving a github repo URL with a trailing slash (#10360)

This commit is contained in:
Jacob MacDonald
2025-10-02 07:34:23 -07:00
committed by GitHub
parent aa8b2abe3d
commit ebbfcda762
2 changed files with 13 additions and 2 deletions

View File

@@ -85,7 +85,11 @@ export function parseGitHubRepoForReleases(source: string): {
// Default to a github repo path, so `source` can be just an org/repo
const parsedUrl = URL.parse(source, 'https://github.com');
// The pathname should be "/owner/repo".
const parts = parsedUrl?.pathname.substring(1).split('/');
const parts = parsedUrl?.pathname
.substring(1)
.split('/')
// Remove the empty segments, fixes trailing slashes
.filter((part) => part !== '');
if (parts?.length !== 2 || parsedUrl?.host !== 'github.com') {
throw new Error(
`Invalid GitHub repository source: ${source}. Expected "owner/repo" or a github repo uri.`,