summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-10-26 23:12:35 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-10-26 23:12:35 (GMT)
commit58f75bcf323e86067147ac66bbb493e6a8c2631f (patch)
tree02c2830b9ef3fbc7ac83b0f6f76d39ab81f4245b
parent87d99c64dfa8880592104245896557aa530d4fd9 (diff)
parent2b07ff3ffa04a3d52bb4aec9df9f8b6378e2f2a7 (diff)
downloadgit-58f75bcf323e86067147ac66bbb493e6a8c2631f.zip
git-58f75bcf323e86067147ac66bbb493e6a8c2631f.tar.gz
git-58f75bcf323e86067147ac66bbb493e6a8c2631f.tar.bz2
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
-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 93dd2bd..fa2596f 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');
}
}
}