X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FTest.pm;h=82a43c13c5949f384bd717a5f3c8889a7add0711;hb=36dbb986bd549b6e6704c81b654b9fef90eb03a8;hp=20bd82761af98cb5aa05d676b5bdebeff35e1c55;hpb=cdae055aa23afa9059f82ae3a7ff877f2341d124;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Test.pm b/lib/Catalyst/Test.pm index 20bd827..82a43c1 100644 --- a/lib/Catalyst/Test.pm +++ b/lib/Catalyst/Test.pm @@ -135,22 +135,31 @@ sub remote_request { my $server = URI->new( $ENV{CATALYST_SERVER} ); if ( $server->path =~ m|^(.+)?/$| ) { - $server->path("$1"); # need to be quoted - } + my $path = $1; + $server->path("$path") if $path; # need to be quoted + } # the request path needs to be sanitised if $server is using a # non-root path due to potential overlap between request path and # response path. if ($server->path) { + # If request path is '/', we have to add a trailing slash to the + # final request URI + my $add_trailing = $request->uri->path eq '/'; + my @sp = split '/', $server->path; my @rp = split '/', $request->uri->path; shift @sp;shift @rp; # leading / if (@rp) { foreach my $sp (@sp) { - shift @rp if $sp eq $rp[0]; + $sp eq $rp[0] ? shift @rp : last } } $request->uri->path(join '/', @rp); + + if ( $add_trailing ) { + $request->uri->path( $request->uri->path . '/' ); + } } $request->uri->scheme( $server->scheme );