my ($self, $name) = @_;
my $rv = $self->{-by_name}->{$name};
return $rv if $rv;
- $self->{-by_name}->{$name} = _fill($self, "publicinbox.$name");
+ $rv = _fill($self, "publicinbox.$name") or return;
+ $self->{-by_name}->{$name} = $rv;
}
sub get {
my $v = $self->{"$pfx.$k"};
$rv->{$k} = $v if defined $v;
}
+ return unless $rv->{mainrepo};
my $inbox = $pfx;
$inbox =~ s/\Apublicinbox\.//;
$rv->{name} = $inbox;
if (my $info = $ng_map->{$ng}) {
my $url = PublicInbox::Hval::prurl($env, $info->{url});
my $code = 301;
- my $h = [ Location => $url, 'Content-Type' => 'text/plain' ];
if (defined $article && $article =~ /\A\d+\z/) {
my $mid = eval { ng_mid_for($ng, $info, $article) };
if (defined $mid) {
}
}
+ my $h = [ Location => $url, 'Content-Type' => 'text/plain' ];
+
return [ $code, $h, [ "Redirecting to $url\n" ] ]
}
[ 404, [ 'Content-Type' => 'text/plain' ], [] ];
my %cfg = (
"$cfgpfx.address" => $addr,
"$cfgpfx.mainrepo" => $maindir,
+ "$cfgpfx.url" => 'http://example.com/test/',
+ "$cfgpfx.newsgroup" => 'inbox.test',
);
while (my ($k,$v) = each %cfg) {
is(0, system(qw(git config --file), $pi_config, $k, $v),
require $psgi;
};
+ # redirect with newsgroup
+ test_psgi($app, sub {
+ my ($cb) = @_;
+ my $from = 'http://example.com/inbox.test';
+ my $to = 'http://example.com/test/';
+ my $res = $cb->(GET($from));
+ is($res->code, 301, 'is permanent redirect');
+ is($to, $res->header('Location'), 'redirect location matches');
+ $from .= '/';
+ is($res->code, 301, 'is permanent redirect');
+ is($to, $res->header('Location'), 'redirect location matches');
+ });
+
# redirect with trailing /
test_psgi($app, sub {
my ($cb) = @_;