Skip to content

Commit 6e9735b

Browse files
committed
Correctly build URLs to file paths containing spaces
Previously, such paths would have their spaces replaced with `/`s, breaking external links to the file. Fixes #249
1 parent 57e14ba commit 6e9735b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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)