* [PATCH] viewdiff: do not generate "a=" parameter if "b=" matches
@ 2020-02-16 10:07 7% Eric Wong
0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2020-02-16 10:07 UTC (permalink / raw)
To: meta
Long URLs waste bandwidth and redundant query parameters
make caching more difficult and expensive.
Fixes: ddec19694cbf0e1d ("viewdiff: rewrite and simplify")
---
lib/PublicInbox/ViewDiff.pm | 7 ++++---
1 file 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('&', @q);
^ permalink raw reply related [relevance 7%]
Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2020-02-16 10:07 7% [PATCH] viewdiff: do not generate "a=" parameter if "b=" matches Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).