From d87095ca15f018cc816eda1639d5c8802b5aeb97 Mon Sep 17 00:00:00 2001 From: rachit367 Date: Thu, 2 Jul 2026 13:54:11 +0530 Subject: [PATCH 1/2] fix(backend): decode percent-encoded repo names for generic Git URLs compileGenericGitHostConfig_url derived the repo name from the raw remoteUrl.pathname, so a direct URL like .../Project%20Name.git kept %20 in name, displayName and zoekt metadata. The file-based path already decodes via decodeURIComponent, so the same remote produced inconsistent identifiers depending on how it was configured. Decode the pathname to match. Fixes #1384 --- packages/backend/src/repoCompileUtils.test.ts | 20 ++++++++++++++++++- packages/backend/src/repoCompileUtils.ts | 4 +++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/repoCompileUtils.test.ts b/packages/backend/src/repoCompileUtils.test.ts index 344079f87..4fb280a48 100644 --- a/packages/backend/src/repoCompileUtils.test.ts +++ b/packages/backend/src/repoCompileUtils.test.ts @@ -255,8 +255,26 @@ describe('compileGenericGitHostConfig_url', () => { expect(result.repoData).toHaveLength(1); expect(result.repoData[0].name).toBe('github.com/test/repo'); - + const metadata = result.repoData[0].metadata as { gitConfig?: Record }; expect(metadata.gitConfig!['zoekt.name']).toBe('github.com/test/repo'); }); + + test('should decode percent-encoded characters in the repo name', async () => { + mockedIsUrlAValidGitRepo.mockResolvedValue(true); + + const config = { + type: 'git' as const, + url: 'https://github.com/test/Project%20Name%20With%20Spaces.git', + }; + + const result = await compileGenericGitHostConfig_url(config, 1); + + expect(result.repoData).toHaveLength(1); + expect(result.repoData[0].name).toBe('github.com/test/Project Name With Spaces'); + expect(result.repoData[0].displayName).toBe('github.com/test/Project Name With Spaces'); + + const metadata = result.repoData[0].metadata as { gitConfig?: Record }; + expect(metadata.gitConfig!['zoekt.name']).toBe('github.com/test/Project Name With Spaces'); + }); }); diff --git a/packages/backend/src/repoCompileUtils.ts b/packages/backend/src/repoCompileUtils.ts index 04632a796..ebd680e57 100644 --- a/packages/backend/src/repoCompileUtils.ts +++ b/packages/backend/src/repoCompileUtils.ts @@ -721,9 +721,11 @@ export const compileGenericGitHostConfig_url = async ( } } + // Decode URL-encoded characters (e.g., %20 -> space) to ensure consistent repo names + const decodedPathname = decodeURIComponent(remoteUrl.pathname); // @note: matches the naming here: // https://github.com/sourcebot-dev/zoekt/blob/main/gitindex/index.go#L293 - const repoName = path.join(remoteUrl.host, remoteUrl.pathname.replace(/\.git$/, '')); + const repoName = path.join(remoteUrl.host, decodedPathname.replace(/\.git$/, '')); const repo: RepoData = { external_codeHostType: 'genericGitHost', From 1aaac6e9e8b20094a94fa036cf4dee80e02cc5fd Mon Sep 17 00:00:00 2001 From: rachit367 Date: Thu, 2 Jul 2026 13:54:51 +0530 Subject: [PATCH 2/2] docs: add changelog entry for generic Git URL decode fix --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea80d6c5e..259db1812 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Maintained the sidebar scroll position when navigating between chats instead of resetting to the top. [#1411](https://github.com/sourcebot-dev/sourcebot/pull/1411) - Upgraded `nodemailer` to `^9.0.1`. [#1356](https://github.com/sourcebot-dev/sourcebot/pull/1356) - Upgraded `@opentelemetry/core` to `^2.8.0`. [#1413](https://github.com/sourcebot-dev/sourcebot/pull/1413) +- Decoded percent-encoded characters in repo names derived from generic Git URLs, so direct URLs match the file-based behavior. [#1415](https://github.com/sourcebot-dev/sourcebot/pull/1415) ## [5.0.4] - 2026-06-18