+ my %umap = (
+ 'm' => '',
+ 'f' => '',
+ 't' => 't/',
+ );
+ while (my ($t, $e) = each %umap) {
+ test_psgi($app, sub {
+ my ($cb) = @_;
+ my $res = $cb->(GET($pfx . "/$t/blah\@example.com.html"));
+ is(301, $res->code, "redirect for old $t .html link");
+ my $location = $res->header('Location');
+ like($location,
+ qr!/blah\@example\.com/$e(?:#u)?\z!,
+ ".html redirected to new location");
+ });
+ }
+ foreach my $sfx (qw(mbox mbox.gz)) {
+ test_psgi($app, sub {
+ my ($cb) = @_;
+ my $res = $cb->(GET($pfx . "/t/blah\@example.com.$sfx"));
+ is(301, $res->code, 'redirect for old thread link');
+ my $location = $res->header('Location');
+ like($location,
+ qr!/blah\@example\.com/t\.mbox(?:\.gz)?\z!,
+ "$sfx redirected to /mbox.gz");
+ });
+ }
+ test_psgi($app, sub {
+ my ($cb) = @_;
+ # for a while, we used to support /$INBOX/$X40/
+ # when we "compressed" long Message-IDs to SHA-1
+ # Now we're stuck supporting them forever :<
+ foreach my $path (@ls) {
+ $path =~ tr!/!!d;
+ my $from = "http://example.com/test/$path/";
+ my $res = $cb->(GET($from));
+ is(301, $res->code, 'is permanent redirect');
+ like($res->header('Location'),
+ qr!/test/blah\@example\.com/!,
+ 'redirect from x40 MIDs works');
+ }
+ });