Re: [PATCH] gitweb: Add js=1 before an URI fragment to fix line number links

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano wrote:
> > Signed-off-by: Peter Stuge <peter@xxxxxxxx>
> 
> Care to elaborate a bit more please?

Okey. I thought subject together with change would be clear enough. :)


> Explanation of what you are fixing is totally lacking.

The subject sums it up, if briefly.


> What happens with the current code, why it is wrong, and how the
> updated pattern improves the result in what way?

Current code generates links to line numbers like ../file.c#l1234;js=1

It is wrong because a URI fragment always goes at the end.

The updated pattern improves this by treating # like end of string,
to detect js=1 also before # and not only at end of string.

The updated code improves this by injecting [?;]js=1 before # if
one exists, or at end of string (like before) otherwise.


> > -var jsExceptionsRe = /[;?]js=[01]$/;
> > +var jsExceptionsRe = /[;?]js=[01](#.*)?$/;
..
> > -		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');

To test how this works you can try it on

http://git.libusb.org/?p=libusb.git;a=blob;f=COPYING

where the change is in production. Compare the line number links with
those generated by another gitweb with javascript-actions enabled.


//Peter
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]