Re: [PATCHv6 5/5] gitweb: generate parent..current URLs
- From
Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
- Date
- Oct 20, 2008, 14:57 UTC
- Message-ID
- <cb7bb73a0810200757h540a699qd9d3ea236fc7b5ad@mail.gmail.com>
- In-Reply-To
- <200810201249.14426.jnareb@gmail.com>
On Mon, Oct 20, 2008 at 12:49 PM, Jakub Narebski <jnareb@gmail.com> wrote:
Show 6 quoted lines
>> - # - hash or hash_base:/filename >> + # - hash_parent or hash_parent_base:/file_parent >> + # - hash or hash_base:/file_name > > Minor nit: this contain independent change 'filename' -> 'file_name', > but I think it is not worth separating...
Oopsie. Oh well, I was getting so used to all those _ that it felt strange without
Show 27 quoted lines
>> # When the script is the root DirectoryIndex for the domain,
>> # $href here would be something like http://gitweb.example.com/
>> @@ -778,17 +779,36 @@ sub href (%) {
>> delete $params{'action'};
>> }
>>
>> - # Finally, we put either hash_base:/file_name or hash
>> + # Next, we put hash_parent_base:/file_parent..hash_base:/file_name,
>> + # stripping nonexistent or useless pieces
>> + $href .= "/" if ($params{'hash_base'} || $params{'hash_parent_base'}
>> + || $params{'hash_parent'} || $params{'hash'});
>
> Nice trick (and required change).
>
>> if (defined $params{'hash_base'}) {
>> - $href .= "/".esc_url($params{'hash_base'});
>> - if (defined $params{'file_name'}) {
>> + if (defined $params{'hash_parent_base'}) {
>> + $href .= esc_url($params{'hash_parent_base'});
>> + # skip the file_parent if it's the same as the file_name
>> + delete $params{'file_parent'} if $params{'file_parent'} eq $params{'file_name'};
>> + if (defined $params{'file_parent'} && $params{'file_parent'} !~ /\.\./) {
>> + $href .= ":/".esc_url($params{'file_parent'});
>> + delete $params{'file_parent'};
>> + }
>
> Side note: I wonder if we should use esc_url or esc_param here...esc_url, I would say, allowing us to build RFC-compliant URLs. Isn't esc_param for CGI?
-- Giuseppe "Oblomov" Bilotta