mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-14 15:21:01 -07:00
fix(cli): allow non-GitHub SCP-styled URLs for extension installation (#13800)
Co-authored-by: Maksym Kursin <maksym.kursin@dkatalis.com>
This commit is contained in:
@@ -136,8 +136,12 @@ describe('github.ts', () => {
|
|||||||
expect(tryParseGithubUrl(url)).toEqual({ owner, repo });
|
expect(tryParseGithubUrl(url)).toEqual({ owner, repo });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return null for non-GitHub URLs', () => {
|
it.each([
|
||||||
expect(tryParseGithubUrl('https://gitlab.com/owner/repo')).toBeNull();
|
'https://gitlab.com/owner/repo',
|
||||||
|
'https://my-git-host.com/owner/group/repo',
|
||||||
|
'git@gitlab.com:some-group/some-project/some-repo.git',
|
||||||
|
])('should return null for non-GitHub URLs', (url) => {
|
||||||
|
expect(tryParseGithubUrl(url)).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw for invalid formats', () => {
|
it('should throw for invalid formats', () => {
|
||||||
|
|||||||
@@ -84,9 +84,15 @@ export interface GithubRepoInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function tryParseGithubUrl(source: string): GithubRepoInfo | null {
|
export function tryParseGithubUrl(source: string): GithubRepoInfo | null {
|
||||||
// First step in normalizing a github ssh URI to the https form.
|
// Handle SCP-style SSH URLs.
|
||||||
if (source.startsWith('git@github.com:')) {
|
if (source.startsWith('git@')) {
|
||||||
source = source.replace('git@github.com:', '');
|
if (source.startsWith('git@github.com:')) {
|
||||||
|
// It's a GitHub SSH URL, so normalize it for the URL parser.
|
||||||
|
source = source.replace('git@github.com:', '');
|
||||||
|
} else {
|
||||||
|
// It's another provider's SSH URL (e.g., gitlab), so not a GitHub repo.
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Default to a github repo path, so `source` can be just an org/repo
|
// Default to a github repo path, so `source` can be just an org/repo
|
||||||
const parsedUrl = URL.parse(source, 'https://github.com');
|
const parsedUrl = URL.parse(source, 'https://github.com');
|
||||||
|
|||||||
Reference in New Issue
Block a user