Add in the REDIRECT_URL handling from trunk and the values for the tests
Tomas Doran [Mon, 24 May 2010 15:44:09 +0000 (15:44 +0000)]
lib/Catalyst/Engine.pm
t/aggregate/unit_core_engine-prepare_path.t

index 17ec97b..29a2188 100644 (file)
@@ -525,7 +525,12 @@ sub prepare_path {
     # set the request URI
     my $path;
     if (!$ctx->config->{use_request_uri_for_path}) {
-        $path = $base_path . $env->{PATH_INFO};
+        my $path_info = $env->{PATH_INFO};
+        if ( exists $env->{REDIRECT_URL} ) {
+            $base_path = $env->{REDIRECT_URL};
+            $base_path =~ s/\Q$path_info\E$//;
+        }
+        $path = $base_path . $path_info;
         $path =~ s{^/+}{};
         $path =~ s/([^$URI::uric])/$URI::Escape::escapes{$1}/go;
         $path =~ s/\?/%3F/g; # STUPID STUPID SPECIAL CASE
index 1fa9750..a7cad81 100644 (file)
@@ -9,6 +9,7 @@ use Catalyst::Engine;
 # mod_rewrite to app root for non / based app
 {
     my $r = get_req (0,
+        REDIRECT_URL => '/comics/',
         SCRIPT_NAME => '/comics/dispatch.cgi',
         REQUEST_URI => '/comics/',
     );
@@ -20,6 +21,7 @@ use Catalyst::Engine;
 {
     my $r = get_req (0,
         PATH_INFO  => '/foo/bar.gif',
+        REDIRECT_URL => '/comics/foo/bar.gif',
         SCRIPT_NAME => '/comics/dispatch.cgi',
         REQUEST_URI => '/comics/foo/bar.gif',
     );