Skip to content

Commit 59b32ff

Browse files
committed
Merge branch 'ps/gitweb-js-with-lineno'
* ps/gitweb-js-with-lineno: gitweb: Fix links to lines in blobs when javascript-actions are enabled
2 parents e579a5d + 2b07ff3 commit 59b32ff

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

gitweb/static/js/javascript-detection.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* and other reasons to not add 'js=1' param at the end of link
1717
* @constant
1818
*/
19-
var jsExceptionsRe = /[;?]js=[01]$/;
19+
var jsExceptionsRe = /[;?]js=[01](#.*)?$/;
2020

2121
/**
2222
* Add '?js=1' or ';js=1' to the end of every link in the document
@@ -33,9 +33,9 @@ function fixLinks() {
3333
var allLinks = document.getElementsByTagName("a") || document.links;
3434
for (var i = 0, len = allLinks.length; i < len; i++) {
3535
var link = allLinks[i];
36-
if (!jsExceptionsRe.test(link)) { // =~ /[;?]js=[01]$/;
37-
link.href +=
38-
(link.href.indexOf('?') === -1 ? '?' : ';') + 'js=1';
36+
if (!jsExceptionsRe.test(link)) {
37+
link.href = link.href.replace(/(#|$)/,
38+
(link.href.indexOf('?') === -1 ? '?' : ';') + 'js=1$1');
3939
}
4040
}
4141
}

0 commit comments

Comments
 (0)