git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gitweb: Add js=1 before an URI fragment to fix line number links
@ 2011-09-26 18:10 Peter Stuge
  2011-09-26 19:27 ` Junio C Hamano
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Peter Stuge @ 2011-09-26 18:10 UTC (permalink / raw)
  To: git

Signed-off-by: Peter Stuge <peter@stuge.se>
---
 gitweb/static/js/javascript-detection.js |    8 ++++----
 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..003acd1 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)) { // =~ /[;?]js=[01](#.*)?$/;
+			link.href = link.href.replace(/(#|$)/,
+				(link.href.indexOf('?') === -1 ? '?' : ';') + 'js=1$1');
 		}
 	}
 }
-- 
1.7.4.1.343.ga91df.dirty

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2011-09-28  1:31 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-26 18:10 [PATCH] gitweb: Add js=1 before an URI fragment to fix line number links Peter Stuge
2011-09-26 19:27 ` Junio C Hamano
2011-09-26 19:46   ` Peter Stuge
2011-09-26 21:14     ` Junio C Hamano
2011-09-26 22:28       ` Peter Stuge
2011-09-27  6:44         ` Johannes Sixt
2011-09-27  9:49           ` Peter Stuge
2011-09-27  9:51             ` [PATCH] gitweb: Fix links to lines in blobs when javascript-actions are enabled Peter Stuge
2011-09-27 17:17               ` Junio C Hamano
2011-09-28  1:31                 ` Peter Stuge
2011-09-27 17:40             ` [PATCH] gitweb: Add js=1 before an URI fragment to fix line number links Junio C Hamano
2011-09-26 23:06 ` Junio C Hamano
2011-09-26 23:17   ` Peter Stuge
2011-09-26 23:19 ` Jakub Narebski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).