From d8393a06dd749eac60e08117b1a893ae0da3d2a5 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Tue, 23 Sep 2025 09:52:42 -0700 Subject: [PATCH] dont attempt to look up releases on github for non-github git uris (#9235) --- packages/cli/src/config/extensions/github.test.ts | 7 +++++++ packages/cli/src/config/extensions/github.ts | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/config/extensions/github.test.ts b/packages/cli/src/config/extensions/github.test.ts index c33d5e84a2..6019cfda57 100644 --- a/packages/cli/src/config/extensions/github.test.ts +++ b/packages/cli/src/config/extensions/github.test.ts @@ -306,6 +306,13 @@ describe('git extension helpers', () => { ); }); + it('should fail on a non-GitHub URL', () => { + const source = 'https://example.com/owner/repo.git'; + expect(() => parseGitHubRepoForReleases(source)).toThrow( + 'Invalid GitHub repository source: https://example.com/owner/repo.git. Expected "owner/repo" or a github repo uri.', + ); + }); + it('should parse owner and repo from a shorthand string', () => { const source = 'owner/repo'; const { owner, repo } = parseGitHubRepoForReleases(source); diff --git a/packages/cli/src/config/extensions/github.ts b/packages/cli/src/config/extensions/github.ts index ead855cb98..28411591d9 100644 --- a/packages/cli/src/config/extensions/github.ts +++ b/packages/cli/src/config/extensions/github.ts @@ -87,7 +87,7 @@ export function parseGitHubRepoForReleases(source: string): { const parsedUrl = URL.parse(source, 'https://github.com'); // The pathname should be "/owner/repo". const parts = parsedUrl?.pathname.substring(1).split('/'); - if (parts?.length !== 2) { + if (parts?.length !== 2 || parsedUrl?.host !== 'github.com') { throw new Error( `Invalid GitHub repository source: ${source}. Expected "owner/repo" or a github repo uri.`, );