about summary refs log tree commit homepage
path: root/lib/PublicInbox
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r--lib/PublicInbox/Config.pm7
-rw-r--r--lib/PublicInbox/Hval.pm6
-rw-r--r--lib/PublicInbox/Inbox.pm2
-rw-r--r--lib/PublicInbox/WwwListing.pm4
4 files changed, 13 insertions, 6 deletions
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
index 8ecf549d..ffc31f83 100644
--- a/lib/PublicInbox/Config.pm
+++ b/lib/PublicInbox/Config.pm
@@ -362,8 +362,8 @@ sub _fill {
         my ($self, $pfx) = @_;
         my $ibx = {};
 
-        foreach my $k (qw(inboxdir filter url newsgroup
-                        infourl watch watchheader httpbackendmax
+        foreach my $k (qw(inboxdir filter newsgroup
+                        watch watchheader httpbackendmax
                         replyto feedmax nntpserver indexlevel)) {
                 my $v = $self->{"$pfx.$k"};
                 $ibx->{$k} = $v if defined $v;
@@ -383,7 +383,8 @@ sub _fill {
         }
         # TODO: more arrays, we should support multi-value for
         # more things to encourage decentralization
-        foreach my $k (qw(address altid nntpmirror coderepo hide listid)) {
+        foreach my $k (qw(address altid nntpmirror coderepo hide listid url
+                        infourl)) {
                 if (defined(my $v = $self->{"$pfx.$k"})) {
                         $ibx->{$k} = _array($v);
                 }
diff --git a/lib/PublicInbox/Hval.pm b/lib/PublicInbox/Hval.pm
index 4a79439f..cd3a4df3 100644
--- a/lib/PublicInbox/Hval.pm
+++ b/lib/PublicInbox/Hval.pm
@@ -86,6 +86,12 @@ sub raw {
 
 sub prurl {
         my ($env, $u) = @_;
+        if (ref($u) eq 'ARRAY') {
+                my $h = $env->{HTTP_HOST} // $env->{SERVER_NAME};
+                my @host_match = grep(/\b\Q$h\E\b/, @$u);
+                $u = $host_match[0] // $u->[0];
+                # fall through to below:
+        }
         index($u, '//') == 0 ? "$env->{'psgi.url_scheme'}:$u" : $u;
 }
 
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index f294c0d5..a3cdcbc0 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -252,7 +252,7 @@ sub base_url {
         } else {
                 # either called from a non-PSGI environment (e.g. NNTP/POP3)
                 $self->{-base_url} ||= do {
-                        my $url = $self->{url} or return undef;
+                        my $url = $self->{url}->[0] or return undef;
                         # expand protocol-relative URLs to HTTPS if we're
                         # not inside a web server
                         $url = "https:$url" if $url =~ m!\A//!;
diff --git a/lib/PublicInbox/WwwListing.pm b/lib/PublicInbox/WwwListing.pm
index 1faade6c..4f076b7d 100644
--- a/lib/PublicInbox/WwwListing.pm
+++ b/lib/PublicInbox/WwwListing.pm
@@ -32,7 +32,7 @@ sub list_all ($$$) {
 sub list_match_domain_i {
         my ($ibx, $arg) = @_;
         my ($list, $hide_key, $re) = @$arg;
-        if (!$ibx->{-hide}->{$hide_key} && $ibx->{url} =~ $re) {
+        if (!$ibx->{-hide}->{$hide_key} && grep($re, @{$ibx->{url}})) {
                 push @$list, $ibx;
         }
 }
@@ -90,7 +90,7 @@ sub ibx_entry {
   ${\$ibx->description}
 
         if (defined(my $info_url = $ibx->{infourl})) {
-                $tmp .= '  ' . $info_url . "\n";
+                $tmp .= '  ' . PublicInbox::Hval::prurl($env, $info_url) . "\n";
         }
         $tmp;
 }