forked from gitea/gitea
1
0
Fork 0

Fix source code line highlighting (#18729) (#18740)

Backport #18729

When the issues repo unit is disabled, or an external issue tracker is used, there is no "a.ref-in-new-issue".

Fixes #18721
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Jimmy Praet 2022-02-12 13:24:49 +01:00 committed by GitHub
parent c04a4afac1
commit edf85b820d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -15,11 +15,14 @@ function selectRange($list, $select, $from) {
const $issue = $('a.ref-in-new-issue');
const $copyPermalink = $('a.copy-line-permalink');
if ($issue.length === 0 || $copyPermalink.length === 0) {
if ($copyPermalink.length === 0) {
return;
}
const updateIssueHref = function(anchor) {
const updateIssueHref = function (anchor) {
if ($issue.length === 0) {
return;
}
let href = $issue.attr('href');
href = `${href.replace(/%23L\d+$|%23L\d+-L\d+$/, '')}%23${anchor}`;
$issue.attr('href', href);