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;
}
# 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);
}
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;
}
} 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//!;
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;
}
}
${\$ibx->description}
if (defined(my $info_url = $ibx->{infourl})) {
- $tmp .= ' ' . $info_url . "\n";
+ $tmp .= ' ' . PublicInbox::Hval::prurl($env, $info_url) . "\n";
}
$tmp;
}
'inboxdir' => '/home/pi/meta-main.git',
'address' => [ 'meta@public-inbox.org' ],
'domain' => 'public-inbox.org',
- 'url' => 'http://example.com/meta',
+ 'url' => [ 'http://example.com/meta' ],
-primary_address => 'meta@public-inbox.org',
'name' => 'meta',
feedmax => 25,
'domain' => 'public-inbox.org',
'name' => 'test',
feedmax => 25,
- 'url' => 'http://example.com/test',
+ 'url' => [ 'http://example.com/test' ],
-httpbackend_limiter => undef,
nntpserver => undef,
}, "lookup matches expected output for test");
address => 'test@example',
name => 'testbox',
inboxdir => $git_dir,
- url => 'http://example.com/test',
+ url => [ 'http://example.com/test' ],
feedmax => 3,
});
my $git = $ibx->git;
use warnings;
use Test::More;
use_ok 'PublicInbox::Inbox';
-my $x = PublicInbox::Inbox->new({url => '//example.com/test/'});
+my $x = PublicInbox::Inbox->new({url => [ '//example.com/test/' ]});
is($x->base_url, 'https://example.com/test/', 'expanded protocol-relative');
-$x = PublicInbox::Inbox->new({url => 'http://example.com/test'});
+$x = PublicInbox::Inbox->new({url => [ 'http://example.com/test' ]});
is($x->base_url, 'http://example.com/test/', 'added trailing slash');
$x = PublicInbox::Inbox->new({});
-primary_address => 'a@example.com',
newsgroup => 'test',
domain => 'example.com',
- url => '//example.com/a'});
+ url => [ '//example.com/a' ]});
is($ng->base_url, $u, 'URL expanded');
my $mid = 'a@b';
my $mime = Email::MIME->new("Message-ID: <$mid>\r\n\r\n");