Skip to content

Commit

Permalink
Merge branch 'ps/gitweb-js-with-lineno'
Browse files Browse the repository at this point in the history
* ps/gitweb-js-with-lineno:
  gitweb: Fix links to lines in blobs when javascript-actions are enabled
  • Loading branch information
Junio C Hamano committed Oct 10, 2011
2 parents e579a5d + 2b07ff3 commit 59b32ff
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gitweb/static/js/javascript-detection.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* and other reasons to not add 'js=1' param at the end of link
* @constant
*/
var jsExceptionsRe = /[;?]js=[01]$/;
var jsExceptionsRe = /[;?]js=[01](#.*)?$/;

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

0 comments on commit 59b32ff

Please sign in to comment.