1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-01 15:56:08 +02:00

Merge branch 'ps/gitweb-js-with-lineno' into maint-1.7.6

* ps/gitweb-js-with-lineno:
  gitweb: Fix links to lines in blobs when javascript-actions are enabled
This commit is contained in:
Junio C Hamano 2011-10-26 16:12:35 -07:00
commit 58f75bcf32

View File

@ -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
@ -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');
}
}
}