Made forward sane again
Sebastian Riedel [Sun, 6 Nov 2005 19:40:33 +0000 (19:40 +0000)]
lib/Catalyst/Dispatcher.pm

index bb7b444..e9d999d 100644 (file)
@@ -80,8 +80,6 @@ sub forward {
     my $c       = shift;
     my $command = shift;
 
-    $command = ref $command if ref $command;
-
     unless ($command) {
         $c->log->debug('Nothing to forward to') if $c->debug;
         return 0;
@@ -91,29 +89,34 @@ sub forward {
 
     my $result;
 
-    my $command_copy = $command;
+    unless ( ref $command ) {
+        my $command_copy = $command;
 
-    unless ( $command_copy =~ s/^\/// ) {
-        my $namespace = $c->namespace;
-        $command_copy = "${namespace}/${command}";
-    }
+        unless ( $command_copy =~ s/^\/// ) {
+            my $namespace = $c->namespace;
+            $command_copy = "${namespace}/${command}";
+        }
 
-    unless ( $command_copy =~ /\// ) {
-        $result = $c->get_action( $command_copy, '/' );
-    }
-    else {
-        my @extra_args;
-      DESCEND: while ( $command_copy =~ s/^(.*)\/(\w+)$/$1/ ) {
-            my $tail = $2;
-            $result = $c->get_action( $tail, $1 );
-            if ($result) {
-                $command = $tail;
-                push( @{$arguments}, @extra_args );
-                last DESCEND;
+        unless ( $command_copy =~ /\// ) {
+            $result = $c->get_action( $command_copy, '/' );
+        }
+        else {
+            my @extra_args;
+          DESCEND: while ( $command_copy =~ s/^(.*)\/(\w+)$/$1/ ) {
+                my $tail = $2;
+                $result = $c->get_action( $tail, $1 );
+                if ($result) {
+                    $command = $tail;
+                    push( @{$arguments}, @extra_args );
+                    last DESCEND;
+                }
+                unshift( @extra_args, $tail );
             }
-            unshift( @extra_args, $tail );
         }
     }
+    else {
+        $result = $command;
+    }
 
     unless ($result) {