- my $pfx = 'http://example.com/test';
- my $path = "/$t/blah%40example.com/";
- my $res = $cb->(GET($pfx . $path));
- is(200, $res->code, "success for $path");
- like($res->content, qr!<title>hihi - Me</title>!,
- "HTML returned");
+ my $res = $cb->(GET($pfx . "/$t/blah\@example.com.txt"));
+ is(301, $res->code, "redirect for old $t .txt link");
+ my $location = $res->header('Location');
+ like($location, qr!/blah\@example\.com/raw\z!,
+ ".txt redirected to /raw");
+ });
+ }
+
+ 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");