X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FTest.pm;h=3aa9878c15476d2289970c90cb167123bfc9db1e;hp=84ba98ad986d4e487ba2ee637b3dc453b8c8682b;hb=76cd7fac9dc64316080d5617166d13bb24f058e5;hpb=a7daf37e6f5527ee3a601bffb3df321e53327d89 diff --git a/lib/Catalyst/Test.pm b/lib/Catalyst/Test.pm index 84ba98a..3aa9878 100644 --- a/lib/Catalyst/Test.pm +++ b/lib/Catalyst/Test.pm @@ -147,10 +147,33 @@ sub remote_request { shift @sp;shift @rp; # leading / if (@rp) { foreach my $sp (@sp) { + shift @rp if $sp eq $rp[0]; + } + } + $request->uri->path(join '/', @rp); + } + + # 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) { $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 );