diff options
author | Eric Wong <e@80x24.org> | 2016-01-09 10:53:10 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-01-09 10:53:14 +0000 |
commit | e70b30144eb62aba848437026bf4e3d5d5ed60c8 (patch) | |
tree | 5cfa27dd795111cf0b24defa3d3841a3ac60fa37 /t/plack.t | |
parent | 5b77f52067420fee90b0e73485639c51154a8b86 (diff) | |
download | public-inbox-e70b30144eb62aba848437026bf4e3d5d5ed60c8.tar.gz |
Sometimes users forget trailing slashes; but we should not punish them with infinite loops.
Diffstat (limited to 't/plack.t')
-rw-r--r-- | t/plack.t | 25 |
1 files changed, 24 insertions, 1 deletions
@@ -81,6 +81,30 @@ EOF is($to, $res->header('Location'), 'redirect location matches'); }); + my $pfx = 'http://example.com/test'; + foreach my $t (qw(t T)) { + test_psgi($app, sub { + my ($cb) = @_; + my $u = $pfx . "/blah%40example.com/$t"; + my $res = $cb->(GET($u)); + is(301, $res->code, "redirect for missing /"); + my $location = $res->header('Location'); + like($location, qr!/\Q$t\E/#u\z!, + 'redirected with missing /'); + }); + } + foreach my $t (qw(f)) { + test_psgi($app, sub { + my ($cb) = @_; + my $u = $pfx . "/blah%40example.com/$t"; + my $res = $cb->(GET($u)); + is(301, $res->code, "redirect for missing /"); + my $location = $res->header('Location'); + like($location, qr!/\Q$t\E/\z!, + 'redirected with missing /'); + }); + } + test_psgi($app, sub { my ($cb) = @_; my $atomurl = 'http://example.com/test/new.atom'; @@ -92,7 +116,6 @@ EOF 'index generated'); }); - my $pfx = 'http://example.com/test'; test_psgi($app, sub { my ($cb) = @_; my $res = $cb->(GET($pfx . '/atom.xml')); |