]> Sergey Matveev's repositories - public-inbox.git/commitdiff
extmsg: favor user-provided URL on partial matches
authorEric Wong <e@80x24.org>
Sun, 17 Jul 2016 23:27:02 +0000 (23:27 +0000)
committerEric Wong <e@80x24.org>
Sun, 17 Jul 2016 23:27:02 +0000 (23:27 +0000)
While an inbox may have multiple URLs, we will favor
the existing URL for the current inbox on partial matches
to avoid confusing users or slowing them down by requiring
a new TCP connection.

lib/PublicInbox/ExtMsg.pm

index 2a9316b1f2c12e466000d62f37f2cf02cb5c6fff..955ada7ee8a6923281c9b3954804cabc18a44e78 100644 (file)
@@ -108,9 +108,11 @@ again:
                $code = 300;
                my $es = $n_partial == 1 ? '' : 'es';
                $s .= "\n$n_partial partial match$es found:\n\n";
+               my $cur_name = $cur->{name};
                foreach my $pair (@partial) {
                        my ($ibx, $res) = @$pair;
-                       my $u = $ibx->base_url or next;
+                       my $env = $ctx->{env} if $ibx->{name} eq $cur_name;
+                       my $u = $ibx->base_url($env) or next;
                        foreach my $m (@$res) {
                                my $p = PublicInbox::Hval->new_msgid($m);
                                my $r = $p->as_href;