Fix Permalink generation for line numbers in code view

To properly escape branch names containing
special characters like `/` (e.g., replaced with `%2F`).
This ensures that copied links work correctly
even when branch names include special characters.
This commit is contained in:
Florian Scholdei
2025-05-27 09:31:37 +02:00
parent 03dc6a49fb
commit 52e1badefb
3 changed files with 4 additions and 2 deletions

View File

@@ -0,0 +1,2 @@
- type: fixed
description: Permalink generation for line numbers in code view

View File

@@ -38,7 +38,7 @@ const SourcecodeViewer: FC<Props> = ({ file, language }) => {
return <Loading />;
}
const permalink = replaceBranchWithRevision(location.pathname, file.revision);
const permalink = replaceBranchWithRevision(location.pathname, encodeURIComponent(file.revision));
return <SyntaxHighlighter language={language.toLowerCase()} value={content || ""} permalink={permalink} />;
};

View File

@@ -47,7 +47,7 @@ const SwitchableMarkdownViewer: FC<Props> = ({ file, basePath, repository }) =>
return <ErrorNotification error={error} />;
}
const permalink = replaceBranchWithRevision(location.pathname, file.revision);
const permalink = replaceBranchWithRevision(location.pathname, encodeURIComponent(file.revision));
return (
<div className="is-relative">