From: Peter Stuge <peter@stuge.se>
To: git@vger.kernel.org
Subject: [PATCH] gitweb: Add js=1 before an URI fragment to fix line number links
Date: Mon, 26 Sep 2011 20:10:42 +0200 [thread overview]
Message-ID: <1317060642-25488-1-git-send-email-peter@stuge.se> (raw)
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
next reply other threads:[~2011-09-26 18:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-26 18:10 Peter Stuge [this message]
2011-09-26 19:27 ` [PATCH] gitweb: Add js=1 before an URI fragment to fix line number links 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1317060642-25488-1-git-send-email-peter@stuge.se \
--to=peter@stuge.se \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).