user/dev discussion of public-inbox itself
 help / color / Atom feed
* [PATCH] viewdiff: do not generate "a=" parameter if "b=" matches
@ 2020-02-16 10:07 Eric Wong
  0 siblings, 0 replies; only message in thread
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	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-16 10:07 [PATCH] viewdiff: do not generate "a=" parameter if "b=" matches Eric Wong

user/dev discussion of public-inbox itself

Archives are clonable:
	git clone --mirror http://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git