aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-10-10 15:56:20 -0700
committerJunio C Hamano <gitster@pobox.com>2011-10-10 15:56:20 -0700
commit59b32ff338da1bd61b0df60386802cfc2edcb54c (patch)
treee8e742f03475556781c9a5458ed048dc50ca8a80
parente579a5d398744e8182decff1329c468d59e6974c (diff)
parent2b07ff3ffa04a3d52bb4aec9df9f8b6378e2f2a7 (diff)
downloadgit-59b32ff338da1bd61b0df60386802cfc2edcb54c.tar.gz
git-59b32ff338da1bd61b0df60386802cfc2edcb54c.tar.xz
Merge branch 'ps/gitweb-js-with-lineno'
* ps/gitweb-js-with-lineno: gitweb: Fix links to lines in blobs when javascript-actions are enabled
-rw-r--r--gitweb/static/js/javascript-detection.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/gitweb/static/js/javascript-detection.js b/gitweb/static/js/javascript-detection.js
index 93dd2bdd9..fa2596f77 100644
--- a/gitweb/static/js/javascript-detection.js
+++ b/gitweb/static/js/javascript-detection.js
@@ -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');
}
}
}