From: Junio C Hamano Date: Mon, 10 Oct 2011 22:56:20 +0000 (-0700) Subject: Merge branch 'ps/gitweb-js-with-lineno' X-Git-Tag: v1.7.8-rc0~103 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/59b32ff338da1bd61b0df60386802cfc2edcb54c?hp=e579a5d398744e8182decff1329c468d59e6974c Merge branch 'ps/gitweb-js-with-lineno' * ps/gitweb-js-with-lineno: gitweb: Fix links to lines in blobs when javascript-actions are enabled --- diff --git a/gitweb/static/js/javascript-detection.js b/gitweb/static/js/javascript-detection.js index 93dd2bdd91..fa2596f77c 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'); } } }