Skip to content

Commit ebf6721

Browse files
authored
Correctly build URLs to file paths containing spaces (#364)
Previously, such paths would have their spaces replaced with `/`s, breaking external links to the file. Fixes #249
1 parent 6d1b813 commit ebf6721

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Fixed
11+
- Fixed issue with external source code links being broken for paths with spaces. [#364](https://github.com/sourcebot-dev/sourcebot/pull/364)
12+
813
## [4.5.0] - 2025-06-21
914

1015
### Added

packages/web/src/features/search/searchApi.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,14 @@ const getFileWebUrl = (template: string, branch: string, fileName: string): stri
106106

107107
const url =
108108
template.substring("{{URLJoinPath ".length, template.indexOf("}}"))
109-
.replace(".Version", branch)
110-
.replace(".Path", fileName)
111109
.split(" ")
112110
.map((part) => {
113111
// remove wrapping quotes
114112
if (part.startsWith("\"")) part = part.substring(1);
115113
if (part.endsWith("\"")) part = part.substring(0, part.length - 1);
114+
// Replace variable references
115+
if (part == ".Version") part = branch;
116+
if (part == ".Path") part = fileName;
116117
return part;
117118
})
118119
.join("/");

0 commit comments

Comments
 (0)