diff --git a/CHANGELOG.md b/CHANGELOG.md index fd9d57a50..ad07d2aef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Skip calling `getCommitHashForRefName` for empty repositories to avoid noisy debug log output. [#914](https://github.com/sourcebot-dev/sourcebot/pull/914) +- 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) ## [4.11.4] - 2026-02-20 diff --git a/packages/backend/src/repoCompileUtils.ts b/packages/backend/src/repoCompileUtils.ts index 9ea3d2e80..a6707b4df 100644 --- a/packages/backend/src/repoCompileUtils.ts +++ b/packages/backend/src/repoCompileUtils.ts @@ -61,7 +61,7 @@ export const compileGithubConfig = async ( const gitHubRepos = gitHubReposResult.repos; const warnings = gitHubReposResult.warnings; - const hostUrl = config.url ?? 'https://github.com'; + const hostUrl = (config.url ?? 'https://github.com').replace(/\/+$/, ''); const repos = gitHubRepos.map((repo) => { const record = createGitHubRepoRecord({ @@ -160,7 +160,7 @@ export const compileGitlabConfig = async ( const gitlabRepos = gitlabReposResult.repos; const warnings = gitlabReposResult.warnings; - const hostUrl = config.url ?? 'https://gitlab.com'; + const hostUrl = (config.url ?? 'https://gitlab.com').replace(/\/+$/, ''); const repoNameRoot = new URL(hostUrl) .toString() .replace(/^https?:\/\//, ''); @@ -242,7 +242,7 @@ export const compileGiteaConfig = async ( const giteaRepos = giteaReposResult.repos; const warnings = giteaReposResult.warnings; - const hostUrl = config.url ?? 'https://gitea.com'; + const hostUrl = (config.url ?? 'https://gitea.com').replace(/\/+$/, ''); const repoNameRoot = new URL(hostUrl) .toString() .replace(/^https?:\/\//, ''); @@ -309,7 +309,7 @@ export const compileGerritConfig = async ( connectionId: number): Promise => { const gerritRepos = await getGerritReposFromConfig(config); - const hostUrl = config.url; + const hostUrl = config.url.replace(/\/+$/, ''); const repoNameRoot = new URL(hostUrl) .toString() .replace(/^https?:\/\//, ''); @@ -396,7 +396,7 @@ export const compileBitbucketConfig = async ( const bitbucketRepos = bitbucketReposResult.repos; const warnings = bitbucketReposResult.warnings; - const hostUrl = config.url ?? 'https://bitbucket.org'; + const hostUrl = (config.url ?? 'https://bitbucket.org').replace(/\/+$/, ''); const repoNameRoot = new URL(hostUrl) .toString() .replace(/^https?:\/\//, ''); @@ -724,7 +724,7 @@ export const compileAzureDevOpsConfig = async ( const azureDevOpsRepos = azureDevOpsReposResult.repos; const warnings = azureDevOpsReposResult.warnings; - const hostUrl = config.url ?? 'https://dev.azure.com'; + const hostUrl = (config.url ?? 'https://dev.azure.com').replace(/\/+$/, ''); const repoNameRoot = new URL(hostUrl) .toString() .replace(/^https?:\/\//, '');