about summary refs log tree commit homepage
path: root/lib/PublicInbox/Repobrowse.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2017-02-15 22:35:18 +0000
committerEric Wong <e@80x24.org>2017-02-16 04:27:50 +0000
commitf6244586ba4f5a5e7575e1254be8c9bbe303fce9 (patch)
treed1a8dd757b632f8cff66e3878f7cfc01e6e2f12d /lib/PublicInbox/Repobrowse.pm
parent993dc7a772b10deda15733c8e750d98bf4d27bd0 (diff)
downloadpublic-inbox-f6244586ba4f5a5e7575e1254be8c9bbe303fce9.tar.gz
Query strings make endpoint caching more difficult since
they're order-independent.  They are also more likely lost
or truncated inadvertantly when copy+pasting, so try to
avoid them for default endpoints.

There's still some things which are broken and followup
commits will be needed to fix them.
Diffstat (limited to 'lib/PublicInbox/Repobrowse.pm')
-rw-r--r--lib/PublicInbox/Repobrowse.pm12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/PublicInbox/Repobrowse.pm b/lib/PublicInbox/Repobrowse.pm
index c16f10fd..2513a105 100644
--- a/lib/PublicInbox/Repobrowse.pm
+++ b/lib/PublicInbox/Repobrowse.pm
@@ -89,7 +89,7 @@ sub call {
         my $method = $env->{REQUEST_METHOD};
         return r(405, 'Method Not Allowed') if ($method !~ /\AGET|HEAD|POST\z/);
 
-        # URL syntax: / repo [ / cmd [ / path ] ]
+        # URL syntax: / repo [ / cmd [ / head [ / path ] ] ]
         # cmd: log | commit | diff | tree | view | blob | snapshot
         # repo and path (@extra) may both contain '/'
         my $path_info = $env->{PATH_INFO};
@@ -116,13 +116,16 @@ sub call {
         my $vcs_lc = $repo_info->{vcs};
         my $vcs = $VCS{$vcs_lc} or return r404();
         my $mod;
+        my $h;
         if (defined $cmd && length $cmd) {
                 $mod = $CMD{$cmd};
-                unless ($mod) {
+                if ($mod) {
+                        $h = shift @extra if @extra;
+                } else {
                         unshift @extra, $cmd;
                         $mod = 'Fallback';
                 }
-                $req->{relcmd} = '../' x scalar(@extra);
+                $req->{relcmd} = '../' x (scalar(@extra) + 1);
         } else {
                 $mod = 'Summary';
                 $cmd = 'summary';
@@ -137,7 +140,8 @@ sub call {
                 pop @extra;
                 ++$tslash;
         }
-
+        $req->{h} = $h;
+        $req->{-tip} = defined $h ? $h : 'HEAD';
         return no_tslash($env) if ($tslash && $NO_TSLASH{$mod});
 
         $req->{tslash} = $tslash;