about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-02-16 04:07:30 -0600
committerEric Wong <e@yhbt.net>2020-02-17 07:54:49 +0000
commit7efca6c8a2b98d97056fc933165df82e4b825725 (patch)
tree8e5d06e3472af219beb4106eb37ed9045d722a9d
parent6b2a40269d00d014c2c94af4bb7dfecff6dff57e (diff)
downloadpublic-inbox-7efca6c8a2b98d97056fc933165df82e4b825725.tar.gz
Long URLs waste bandwidth and redundant query parameters
make caching more difficult and expensive.

Fixes: ddec19694cbf0e1d ("viewdiff: rewrite and simplify")
-rw-r--r--lib/PublicInbox/ViewDiff.pm7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/PublicInbox/ViewDiff.pm b/lib/PublicInbox/ViewDiff.pm
index b2dcbf8f..604b1f23 100644
--- a/lib/PublicInbox/ViewDiff.pm
+++ b/lib/PublicInbox/ViewDiff.pm
@@ -106,17 +106,18 @@ sub diff_header ($$$$) {
         my (undef, undef, $pa, $pb) = splice(@$top, 0, 4); # ignore oid_{a,b}
         my $spfx = $ctx->{-spfx};
         my $dctx = { spfx => $spfx };
+
+        # get rid of leading "a/" or "b/" (or whatever --{src,dst}-prefix are)
+        $pa = (split('/', git_unquote($pa), 2))[1] if $pa ne '/dev/null';
+        $pb = (split('/', git_unquote($pb), 2))[1] if $pb ne '/dev/null';
         if ($pa eq $pb && $pb ne '/dev/null') {
-                $pa = $pb = (split('/', git_unquote($pb), 2))[1];
                 $dctx->{Q} = "?b=".uri_escape_utf8($pb, UNSAFE);
         } else {
                 my @q;
                 if ($pb ne '/dev/null') {
-                        $pb = (split('/', git_unquote($pb), 2))[1];
                         push @q, 'b='.uri_escape_utf8($pb, UNSAFE);
                 }
                 if ($pa ne '/dev/null') {
-                        $pa = (split('/', git_unquote($pa), 2))[1];
                         push @q, 'a='.uri_escape_utf8($pa, UNSAFE);
                 }
                 $dctx->{Q} = '?'.join('&amp;', @q);