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
This commit is contained in:
Chris Roberts 2025-06-24 13:57:55 -05:00 committed by GitHub
parent 6d1b8136ae
commit ebf6721836
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View file

@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Fixed
- Fixed issue with external source code links being broken for paths with spaces. [#364](https://github.com/sourcebot-dev/sourcebot/pull/364)
## [4.5.0] - 2025-06-21
### Added

View file

@ -106,13 +106,14 @@ const getFileWebUrl = (template: string, branch: string, fileName: string): stri
const url =
template.substring("{{URLJoinPath ".length, template.indexOf("}}"))
.replace(".Version", branch)
.replace(".Path", fileName)
.split(" ")
.map((part) => {
// remove wrapping quotes
if (part.startsWith("\"")) part = part.substring(1);
if (part.endsWith("\"")) part = part.substring(0, part.length - 1);
// Replace variable references
if (part == ".Version") part = branch;
if (part == ".Path") part = fileName;
return part;
})
.join("/");