Skip to content

Instantly share code, notes, and snippets.

@nicomen
Last active October 22, 2015 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicomen/dd12511cf4ac012fb733 to your computer and use it in GitHub Desktop.
Save nicomen/dd12511cf4ac012fb733 to your computer and use it in GitHub Desktop.
Test for handling non-leading slash in specific NGiNX environment
use Test::Mojo;
use Test::More;
my $t = Test::Mojo->new('MyApp');
# FOO-3707: wrong redirect
my $url = $t->ua->server->url;
my $tx = $t->ua->build_tx('GET' => $url);
$tx->req->url->path("path_that_redirects"); # Location: $self->req->url->path =~ s{/$}{};
$tx->req->{start_buffer} = "GET path_that_redirects/ HTTP/1.1\r\n";
$tx = $t->ua->start($tx);
is $tx->res->headers->location, '/path_that_redirects', 'Redirect address has a leading slash and no trailing slash';
done_testing;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment