X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FTest.pm;h=9f2f7bed59a65a2798d308fa2a03aa2444b983ab;hb=f4c0f6f787fe962604cf62cf7ad7c87f0c59b673;hp=b3c25cc7fa7a0d3e221b2abe7d6cb10dbac2ced7;hpb=f13fc03fe888214323259fd26fe0cb81b7832beb;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Test.pm b/lib/Catalyst/Test.pm index b3c25cc..9f2f7be 100644 --- a/lib/Catalyst/Test.pm +++ b/lib/Catalyst/Test.pm @@ -138,6 +138,29 @@ sub remote_request { $server->path("$1"); # 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) { + $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 ); $request->uri->host( $server->host ); $request->uri->port( $server->port );