diff options
author | Eric Wong <e@80x24.org> | 2015-08-27 04:34:02 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-08-27 06:04:51 +0000 |
commit | 3ed9085b7445fb3b7f7f5eed107dce63e4bc3bf3 (patch) | |
tree | 49ce865379e341b608237029831798cc4aa6c377 /t | |
parent | 9a2931759c3dcbd879728b49151aa3f8a641b506 (diff) | |
download | public-inbox-3ed9085b7445fb3b7f7f5eed107dce63e4bc3bf3.tar.gz |
We should not break existing URLs. Redirect them to the newer, less-ambiguous URLs to improve cache hit ratios.
Diffstat (limited to 't')
-rw-r--r-- | t/plack.t | 36 |
1 files changed, 33 insertions, 3 deletions
@@ -92,9 +92,9 @@ EOF 'index generated'); }); + my $pfx = 'http://example.com/test'; test_psgi($app, sub { my ($cb) = @_; - my $pfx = 'http://example.com/test'; my $res = $cb->(GET($pfx . '/atom.xml')); is(200, $res->code, 'success response received for atom'); like($res->content, @@ -105,7 +105,6 @@ EOF foreach my $t (qw(f m)) { test_psgi($app, sub { my ($cb) = @_; - 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"); @@ -115,11 +114,42 @@ EOF } test_psgi($app, sub { my ($cb) = @_; - my $pfx = 'http://example.com/test'; my $res = $cb->(GET($pfx . '/m/blah%40example.com/raw')); is(200, $res->code, 'success response received for /m/*/raw'); like($res->content, qr!\AFrom !, "mbox returned"); }); + + # legacy redirects + foreach my $t (qw(m f)) { + test_psgi($app, sub { + my ($cb) = @_; + my $res = $cb->(GET($pfx . "/$t/blah%40example.com.txt")); + is(301, $res->code, "redirect for old $t .txt link"); + my $location = $res->header('Location'); + like($location, qr!/$t/blah%40example\.com/raw\z!, + ".txt redirected to /raw"); + }); + } + foreach my $t (qw(m f t)) { + test_psgi($app, sub { + my ($cb) = @_; + my $res = $cb->(GET($pfx . "/$t/blah%40example.com.html")); + is(301, $res->code, "redirect for old $t .html link"); + my $location = $res->header('Location'); + like($location, qr!/$t/blah%40example\.com/(?:#u)?\z!, + ".html redirected to /raw"); + }); + } + foreach my $sfx (qw(mbox mbox.gz)) { + test_psgi($app, sub { + my ($cb) = @_; + my $res = $cb->(GET($pfx . "/t/blah%40example.com.$sfx")); + is(301, $res->code, 'redirect for old thread link'); + my $location = $res->header('Location'); + like($location, qr!/t/blah%40example\.com/mbox\.gz\z!, + "$sfx redirected to /mbox.gz"); + }); + } } done_testing(); |