Skip to content

Commit c752a0e

Browse files
Oblomovgitster
authored andcommitted
gitweb: embed snapshot format parameter in PATH_INFO
When PATH_INFO is active, get rid of the sf CGI parameter by embedding the snapshot format information in the PATH_INFO URL, in the form of an appropriate extension. Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 1ec2fb5 commit c752a0e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

gitweb/gitweb.perl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,7 @@ (%)
811811
# - action
812812
# - hash_parent or hash_parent_base:/file_parent
813813
# - hash or hash_base:/filename
814+
# - the snapshot_format as an appropriate suffix
814815

815816
# When the script is the root DirectoryIndex for the domain,
816817
# $href here would be something like http://gitweb.example.com/
@@ -822,6 +823,10 @@ (%)
822823
$href .= "/".esc_url($params{'project'}) if defined $params{'project'};
823824
delete $params{'project'};
824825

826+
# since we destructively absorb parameters, we keep this
827+
# boolean that remembers if we're handling a snapshot
828+
my $is_snapshot = $params{'action'} eq 'snapshot';
829+
825830
# Summary just uses the project path URL, any other action is
826831
# added to the URL
827832
if (defined $params{'action'}) {
@@ -861,6 +866,18 @@ (%)
861866
$href .= esc_url($params{'hash'});
862867
delete $params{'hash'};
863868
}
869+
870+
# If the action was a snapshot, we can absorb the
871+
# snapshot_format parameter too
872+
if ($is_snapshot) {
873+
my $fmt = $params{'snapshot_format'};
874+
# snapshot_format should always be defined when href()
875+
# is called, but just in case some code forgets, we
876+
# fall back to the default
877+
$fmt ||= $snapshot_fmts[0];
878+
$href .= $known_snapshot_formats{$fmt}{'suffix'};
879+
delete $params{'snapshot_format'};
880+
}
864881
}
865882

866883
# now encode the parameters explicitly

0 commit comments

Comments
 (0)