Skip to content

Commit fdae9e7

Browse files
fix: remove trailing slashes from host url to fix links to code host platforms (#915)
* Fix double slash in GitLab and Azure DevOps web URLs When users configure a GitLab or Azure DevOps connection with a trailing slash in the URL (e.g., https://gitlab.example.com/), the constructed project URLs would have a double slash (https://gitlab.example.com//path) causing 404 errors when opening links. This fix strips trailing slashes from the hostUrl before constructing URLs. Fixes SOU-533 Co-authored-by: Michael Sukkarieh <msukkari@users.noreply.github.com> * Add changelog entry for PR #915 Co-authored-by: Michael Sukkarieh <msukkari@users.noreply.github.com> * Strip all trailing slashes from host URLs Changed regex from /\\/$/ to /\\/+$/ to handle cases where there might be multiple trailing slashes in the configured URL. Co-authored-by: Michael Sukkarieh <msukkari@users.noreply.github.com> * remove all trailing slashes for all code host platforms --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Michael Sukkarieh <msukkari@users.noreply.github.com>
1 parent 92eefde commit fdae9e7

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Fixed
1111
- Skip calling `getCommitHashForRefName` for empty repositories to avoid noisy debug log output. [#914](https://github.com/sourcebot-dev/sourcebot/pull/914)
12+
- Fixed "Open in GitLab" links having a double slash when the GitLab host URL is configured with a trailing slash. [#915](https://github.com/sourcebot-dev/sourcebot/pull/915)
1213

1314
## [4.11.4] - 2026-02-20
1415

packages/backend/src/repoCompileUtils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const compileGithubConfig = async (
6161
const gitHubRepos = gitHubReposResult.repos;
6262
const warnings = gitHubReposResult.warnings;
6363

64-
const hostUrl = config.url ?? 'https://github.com';
64+
const hostUrl = (config.url ?? 'https://github.com').replace(/\/+$/, '');
6565

6666
const repos = gitHubRepos.map((repo) => {
6767
const record = createGitHubRepoRecord({
@@ -160,7 +160,7 @@ export const compileGitlabConfig = async (
160160
const gitlabRepos = gitlabReposResult.repos;
161161
const warnings = gitlabReposResult.warnings;
162162

163-
const hostUrl = config.url ?? 'https://gitlab.com';
163+
const hostUrl = (config.url ?? 'https://gitlab.com').replace(/\/+$/, '');
164164
const repoNameRoot = new URL(hostUrl)
165165
.toString()
166166
.replace(/^https?:\/\//, '');
@@ -242,7 +242,7 @@ export const compileGiteaConfig = async (
242242
const giteaRepos = giteaReposResult.repos;
243243
const warnings = giteaReposResult.warnings;
244244

245-
const hostUrl = config.url ?? 'https://gitea.com';
245+
const hostUrl = (config.url ?? 'https://gitea.com').replace(/\/+$/, '');
246246
const repoNameRoot = new URL(hostUrl)
247247
.toString()
248248
.replace(/^https?:\/\//, '');
@@ -309,7 +309,7 @@ export const compileGerritConfig = async (
309309
connectionId: number): Promise<CompileResult> => {
310310

311311
const gerritRepos = await getGerritReposFromConfig(config);
312-
const hostUrl = config.url;
312+
const hostUrl = config.url.replace(/\/+$/, '');
313313
const repoNameRoot = new URL(hostUrl)
314314
.toString()
315315
.replace(/^https?:\/\//, '');
@@ -396,7 +396,7 @@ export const compileBitbucketConfig = async (
396396
const bitbucketRepos = bitbucketReposResult.repos;
397397
const warnings = bitbucketReposResult.warnings;
398398

399-
const hostUrl = config.url ?? 'https://bitbucket.org';
399+
const hostUrl = (config.url ?? 'https://bitbucket.org').replace(/\/+$/, '');
400400
const repoNameRoot = new URL(hostUrl)
401401
.toString()
402402
.replace(/^https?:\/\//, '');
@@ -724,7 +724,7 @@ export const compileAzureDevOpsConfig = async (
724724
const azureDevOpsRepos = azureDevOpsReposResult.repos;
725725
const warnings = azureDevOpsReposResult.warnings;
726726

727-
const hostUrl = config.url ?? 'https://dev.azure.com';
727+
const hostUrl = (config.url ?? 'https://dev.azure.com').replace(/\/+$/, '');
728728
const repoNameRoot = new URL(hostUrl)
729729
.toString()
730730
.replace(/^https?:\/\//, '');

0 commit comments

Comments
 (0)