about summary refs log tree commit homepage
path: root/lib/PublicInbox/Hval.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-01-02 03:09:30 +0000
committerEric Wong <e@80x24.org>2020-01-02 20:56:24 +0000
commit1988d730c0088e8b1f6193650c7ee929df8a2ed7 (patch)
tree91920176afd1fd05e2649204c530a68ca657b03a /lib/PublicInbox/Hval.pm
parent78fe6a9e601fcf3ec2983c82edaeb825e61275cf (diff)
downloadpublic-inbox-1988d730c0088e8b1f6193650c7ee929df8a2ed7.tar.gz
Since the beginning of this project, we've implicitly supported
inboxes with multiple URLs by relying on the Host: header sent
by the client ($env->{HTTP_HOST}).

We now offer the option to explicitly configure multiple URLs for
every inbox along with the ability to do a best-effort match for
matching hostnames.
Diffstat (limited to 'lib/PublicInbox/Hval.pm')
-rw-r--r--lib/PublicInbox/Hval.pm6
1 files changed, 6 insertions, 0 deletions
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;
 }