From: Jakub Narebski <jnareb@gmail.com>
To: Peter Stuge <peter@stuge.se>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] gitweb: Add js=1 before an URI fragment to fix line number links
Date: Mon, 26 Sep 2011 16:19:25 -0700 (PDT) [thread overview]
Message-ID: <m339fiq4dx.fsf@localhost.localdomain> (raw)
In-Reply-To: <1317060642-25488-1-git-send-email-peter@stuge.se>
Peter Stuge <peter@stuge.se> writes:
It really needs a proper commit message. Perhaps something like this:
The fixLinks() function in javascript-detection.js is supposed to
add 'js' query parameter with a value of 1 to each link that does
not have 'js' query parameter already.
However it didn't take into account the fact that URI can have
'fragment' part. It meant that:
1. URIs with fragment and 'js' query parameter, like e.g.
...foo?js=0#l199
were not recognized as having 'js' query parameter already.
2. The 'js' query parameter, in the form of either '?js=1' or ';js=1'
was appended at the end of URI, even if it included a fragment
(had a hash part). This lead to the incorrect links like this
...foo#l199?js=1
instead of adding query parameter as last part of query, but
before the fragment part, i.e.
...foo?js=1#l199
> Signed-off-by: Peter Stuge <peter@stuge.se>
For what it is worth it
Acked-by: Jakub Narebski <jnareb@gmail.com>
> ---
> 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
>
--
Jakub Narębski mailto:jnareb@fuw.edu.pl
ZTHiL IFT UW http://info.fuw.edu.pl/~jnareb/
prev parent reply other threads:[~2011-09-26 23:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
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=m339fiq4dx.fsf@localhost.localdomain \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
--cc=peter@stuge.se \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.