From aaeed30a6feee605db6fb37ea73acd25c0a74ed5 Mon Sep 17 00:00:00 2001 From: OM MISHRA <152969928+howwohmm@users.noreply.github.com> Date: Tue, 24 Mar 2026 02:23:22 +0530 Subject: [PATCH 1/5] test(useRepositoryUrl): add regression tests for monorepo .git URL handling Co-Authored-By: Claude Opus 4.6 --- .../composables/use-repository-url.spec.ts | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 test/nuxt/composables/use-repository-url.spec.ts diff --git a/test/nuxt/composables/use-repository-url.spec.ts b/test/nuxt/composables/use-repository-url.spec.ts new file mode 100644 index 0000000000..0d3ea9a3b7 --- /dev/null +++ b/test/nuxt/composables/use-repository-url.spec.ts @@ -0,0 +1,74 @@ +import { describe, expect, it } from 'vitest' + +/** + * Tests for useRepositoryUrl composable. + * + * Regression tests for GitHub issue #2233: monorepo packages with .git suffix + * in repository.url generated broken source links like: + * https://github.com/org/repo.git/tree/HEAD/packages/foo (404) + * instead of: + * https://github.com/org/repo/tree/HEAD/packages/foo + */ +describe('useRepositoryUrl', () => { + it('should strip .git from repository URL', () => { + const { repositoryUrl } = useRepositoryUrl(ref({ + repository: { + type: 'git', + url: 'git+https://github.com/agentmarkup/agentmarkup.git', + }, + })) + + expect(repositoryUrl.value).toBe('https://github.com/agentmarkup/agentmarkup') + }) + + it('should append /tree/HEAD/{directory} for monorepo packages without .git', () => { + const { repositoryUrl } = useRepositoryUrl(ref({ + repository: { + type: 'git', + url: 'git+https://github.com/agentmarkup/agentmarkup.git', + directory: 'packages/vite', + }, + })) + + expect(repositoryUrl.value).toBe( + 'https://github.com/agentmarkup/agentmarkup/tree/HEAD/packages/vite', + ) + }) + + it('should return null when repository has no url', () => { + const { repositoryUrl } = useRepositoryUrl(ref({ + repository: {}, + })) + + expect(repositoryUrl.value).toBeNull() + }) + + it('should return null when no repository field', () => { + const { repositoryUrl } = useRepositoryUrl(ref({})) + + expect(repositoryUrl.value).toBeNull() + }) + + it('should handle plain HTTPS URLs without .git suffix', () => { + const { repositoryUrl } = useRepositoryUrl(ref({ + repository: { + url: 'https://github.com/nuxt/ui', + }, + })) + + expect(repositoryUrl.value).toBe('https://github.com/nuxt/ui') + }) + + it('should handle directory with trailing slash', () => { + const { repositoryUrl } = useRepositoryUrl(ref({ + repository: { + url: 'git+https://github.com/org/repo.git', + directory: 'packages/core/', + }, + })) + + expect(repositoryUrl.value).toBe( + 'https://github.com/org/repo/tree/HEAD/packages/core/', + ) + }) +}) From 1a301a2f0017bc9576d59e577770d58608bd34e6 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Mon, 23 Mar 2026 21:00:27 +0000 Subject: [PATCH 2/5] [autofix.ci] apply automated fixes --- .../composables/use-repository-url.spec.ts | 68 +++++++++++-------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/test/nuxt/composables/use-repository-url.spec.ts b/test/nuxt/composables/use-repository-url.spec.ts index 0d3ea9a3b7..197a89abac 100644 --- a/test/nuxt/composables/use-repository-url.spec.ts +++ b/test/nuxt/composables/use-repository-url.spec.ts @@ -11,24 +11,28 @@ import { describe, expect, it } from 'vitest' */ describe('useRepositoryUrl', () => { it('should strip .git from repository URL', () => { - const { repositoryUrl } = useRepositoryUrl(ref({ - repository: { - type: 'git', - url: 'git+https://github.com/agentmarkup/agentmarkup.git', - }, - })) + const { repositoryUrl } = useRepositoryUrl( + ref({ + repository: { + type: 'git', + url: 'git+https://github.com/agentmarkup/agentmarkup.git', + }, + }), + ) expect(repositoryUrl.value).toBe('https://github.com/agentmarkup/agentmarkup') }) it('should append /tree/HEAD/{directory} for monorepo packages without .git', () => { - const { repositoryUrl } = useRepositoryUrl(ref({ - repository: { - type: 'git', - url: 'git+https://github.com/agentmarkup/agentmarkup.git', - directory: 'packages/vite', - }, - })) + const { repositoryUrl } = useRepositoryUrl( + ref({ + repository: { + type: 'git', + url: 'git+https://github.com/agentmarkup/agentmarkup.git', + directory: 'packages/vite', + }, + }), + ) expect(repositoryUrl.value).toBe( 'https://github.com/agentmarkup/agentmarkup/tree/HEAD/packages/vite', @@ -36,9 +40,11 @@ describe('useRepositoryUrl', () => { }) it('should return null when repository has no url', () => { - const { repositoryUrl } = useRepositoryUrl(ref({ - repository: {}, - })) + const { repositoryUrl } = useRepositoryUrl( + ref({ + repository: {}, + }), + ) expect(repositoryUrl.value).toBeNull() }) @@ -50,25 +56,27 @@ describe('useRepositoryUrl', () => { }) it('should handle plain HTTPS URLs without .git suffix', () => { - const { repositoryUrl } = useRepositoryUrl(ref({ - repository: { - url: 'https://github.com/nuxt/ui', - }, - })) + const { repositoryUrl } = useRepositoryUrl( + ref({ + repository: { + url: 'https://github.com/nuxt/ui', + }, + }), + ) expect(repositoryUrl.value).toBe('https://github.com/nuxt/ui') }) it('should handle directory with trailing slash', () => { - const { repositoryUrl } = useRepositoryUrl(ref({ - repository: { - url: 'git+https://github.com/org/repo.git', - directory: 'packages/core/', - }, - })) - - expect(repositoryUrl.value).toBe( - 'https://github.com/org/repo/tree/HEAD/packages/core/', + const { repositoryUrl } = useRepositoryUrl( + ref({ + repository: { + url: 'git+https://github.com/org/repo.git', + directory: 'packages/core/', + }, + }), ) + + expect(repositoryUrl.value).toBe('https://github.com/org/repo/tree/HEAD/packages/core/') }) }) From 09a6ac2417c2616122fd49159aac86fd235b747b Mon Sep 17 00:00:00 2001 From: OM MISHRA <152969928+howwohmm@users.noreply.github.com> Date: Tue, 24 Mar 2026 02:42:48 +0530 Subject: [PATCH 3/5] fix: add type casts to test mocks for vue-tsc compatibility Co-Authored-By: Claude Opus 4.6 --- test/nuxt/composables/use-repository-url.spec.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/nuxt/composables/use-repository-url.spec.ts b/test/nuxt/composables/use-repository-url.spec.ts index 197a89abac..3e269b0aa0 100644 --- a/test/nuxt/composables/use-repository-url.spec.ts +++ b/test/nuxt/composables/use-repository-url.spec.ts @@ -17,7 +17,7 @@ describe('useRepositoryUrl', () => { type: 'git', url: 'git+https://github.com/agentmarkup/agentmarkup.git', }, - }), + } as any), ) expect(repositoryUrl.value).toBe('https://github.com/agentmarkup/agentmarkup') @@ -31,7 +31,7 @@ describe('useRepositoryUrl', () => { url: 'git+https://github.com/agentmarkup/agentmarkup.git', directory: 'packages/vite', }, - }), + } as any), ) expect(repositoryUrl.value).toBe( @@ -43,14 +43,14 @@ describe('useRepositoryUrl', () => { const { repositoryUrl } = useRepositoryUrl( ref({ repository: {}, - }), + } as any), ) expect(repositoryUrl.value).toBeNull() }) it('should return null when no repository field', () => { - const { repositoryUrl } = useRepositoryUrl(ref({})) + const { repositoryUrl } = useRepositoryUrl(ref({} as any)) expect(repositoryUrl.value).toBeNull() }) @@ -61,7 +61,7 @@ describe('useRepositoryUrl', () => { repository: { url: 'https://github.com/nuxt/ui', }, - }), + } as any), ) expect(repositoryUrl.value).toBe('https://github.com/nuxt/ui') @@ -74,7 +74,7 @@ describe('useRepositoryUrl', () => { url: 'git+https://github.com/org/repo.git', directory: 'packages/core/', }, - }), + } as any), ) expect(repositoryUrl.value).toBe('https://github.com/org/repo/tree/HEAD/packages/core/') From 89509f70fc93608b020bf7b8f7e750101e9d7c2d Mon Sep 17 00:00:00 2001 From: "Willow (GHOST)" Date: Tue, 24 Mar 2026 00:14:22 -0700 Subject: [PATCH 4/5] chore: remove comment --- test/nuxt/composables/use-repository-url.spec.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/test/nuxt/composables/use-repository-url.spec.ts b/test/nuxt/composables/use-repository-url.spec.ts index 3e269b0aa0..4e13e8f1e6 100644 --- a/test/nuxt/composables/use-repository-url.spec.ts +++ b/test/nuxt/composables/use-repository-url.spec.ts @@ -1,14 +1,5 @@ import { describe, expect, it } from 'vitest' -/** - * Tests for useRepositoryUrl composable. - * - * Regression tests for GitHub issue #2233: monorepo packages with .git suffix - * in repository.url generated broken source links like: - * https://github.com/org/repo.git/tree/HEAD/packages/foo (404) - * instead of: - * https://github.com/org/repo/tree/HEAD/packages/foo - */ describe('useRepositoryUrl', () => { it('should strip .git from repository URL', () => { const { repositoryUrl } = useRepositoryUrl( From 0103106925fbefe6b5d87fc93f6424e501058889 Mon Sep 17 00:00:00 2001 From: "Willow (GHOST)" Date: Tue, 24 Mar 2026 00:26:20 -0700 Subject: [PATCH 5/5] fix: type errors --- .../composables/use-repository-url.spec.ts | 66 +++++++++---------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/test/nuxt/composables/use-repository-url.spec.ts b/test/nuxt/composables/use-repository-url.spec.ts index 4e13e8f1e6..b66ff46ef6 100644 --- a/test/nuxt/composables/use-repository-url.spec.ts +++ b/test/nuxt/composables/use-repository-url.spec.ts @@ -1,14 +1,25 @@ import { describe, expect, it } from 'vitest' +type RequestedVersion = Exclude + +function mockPackage(repository: RequestedVersion['repository']): RequestedVersion { + return { + _id: 'foo', + name: 'foo', + dist: { shasum: 'foo', signatures: [], tarball: '' }, + _npmVersion: '', + version: '0.1.0', + repository, + } +} + describe('useRepositoryUrl', () => { it('should strip .git from repository URL', () => { const { repositoryUrl } = useRepositoryUrl( - ref({ - repository: { - type: 'git', - url: 'git+https://github.com/agentmarkup/agentmarkup.git', - }, - } as any), + mockPackage({ + type: 'git', + url: 'git+https://github.com/agentmarkup/agentmarkup.git', + }), ) expect(repositoryUrl.value).toBe('https://github.com/agentmarkup/agentmarkup') @@ -16,13 +27,11 @@ describe('useRepositoryUrl', () => { it('should append /tree/HEAD/{directory} for monorepo packages without .git', () => { const { repositoryUrl } = useRepositoryUrl( - ref({ - repository: { - type: 'git', - url: 'git+https://github.com/agentmarkup/agentmarkup.git', - directory: 'packages/vite', - }, - } as any), + mockPackage({ + type: 'git', + url: 'git+https://github.com/agentmarkup/agentmarkup.git', + directory: 'packages/vite', + }), ) expect(repositoryUrl.value).toBe( @@ -31,41 +40,28 @@ describe('useRepositoryUrl', () => { }) it('should return null when repository has no url', () => { - const { repositoryUrl } = useRepositoryUrl( - ref({ - repository: {}, - } as any), - ) - + // @ts-expect-error tests + const { repositoryUrl } = useRepositoryUrl(mockPackage({})) expect(repositoryUrl.value).toBeNull() }) it('should return null when no repository field', () => { - const { repositoryUrl } = useRepositoryUrl(ref({} as any)) - + // @ts-expect-error tests + const { repositoryUrl } = useRepositoryUrl(mockPackage()) expect(repositoryUrl.value).toBeNull() }) it('should handle plain HTTPS URLs without .git suffix', () => { - const { repositoryUrl } = useRepositoryUrl( - ref({ - repository: { - url: 'https://github.com/nuxt/ui', - }, - } as any), - ) - + const { repositoryUrl } = useRepositoryUrl(mockPackage({ url: 'https://github.com/nuxt/ui' })) expect(repositoryUrl.value).toBe('https://github.com/nuxt/ui') }) it('should handle directory with trailing slash', () => { const { repositoryUrl } = useRepositoryUrl( - ref({ - repository: { - url: 'git+https://github.com/org/repo.git', - directory: 'packages/core/', - }, - } as any), + mockPackage({ + url: 'git+https://github.com/org/repo.git', + directory: 'packages/core/', + }), ) expect(repositoryUrl.value).toBe('https://github.com/org/repo/tree/HEAD/packages/core/')