Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Prevented browser performance instrumentation from breaking code views when `performance.measure()` returns no value. [#1665](https://github.com/sourcebot-dev/sourcebot/pull/1665)
- Decoded percent-encoded characters in repo names derived from direct generic git URLs. [#1666](https://github.com/sourcebot-dev/sourcebot/pull/1666)

## [5.1.13] - 2026-09-12

Expand Down
20 changes: 20 additions & 0 deletions packages/backend/src/repoCompileUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,24 @@ describe('compileGenericGitHostConfig_url', () => {
const metadata = result[0].metadata as { gitConfig?: Record<string, string> };
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).toHaveLength(1);
// The repo name should have decoded spaces, not %20
expect(result[0].name).toBe('github.com/test/Project Name With Spaces');
expect(result[0].displayName).toBe('github.com/test/Project Name With Spaces');

const metadata = result[0].metadata as { gitConfig?: Record<string, string> };
expect(metadata.gitConfig!['zoekt.name']).toBe('github.com/test/Project Name With Spaces');
expect(metadata.gitConfig!['zoekt.display-name']).toBe('github.com/test/Project Name With Spaces');
});
});
23 changes: 22 additions & 1 deletion packages/backend/src/repoCompileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,28 @@ export const compileGenericGitHostConfig_url = async (

// @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$/, ''));
// Decode URL-encoded characters (e.g., %20 -> space) to ensure consistent repo names
let decodedPathname: string;
try {
decodedPathname = decodeURIComponent(remoteUrl.pathname);
} catch (e) {
if (e instanceof URIError) {
const warning = `Skipping ${remoteUrl.toString()} - malformed URL encoding.`;
logger.warn(warning);
reportRepositoryDiscoveryIssue({
code: "INVALID_REPOSITORY_SOURCE",
effect: "TARGET_SKIPPED",
subject: {
kind: "url",
value: remoteUrl.toString(),
},
message: warning,
});
return [];
}
throw e;
}
const repoName = path.join(remoteUrl.host, decodedPathname.replace(/\.git$/, ''));

const repo: RepoData = {
external_codeHostType: 'genericGitHost',
Expand Down