rework $c->stats to cooperate with new subrequest plugin
[catagits/Catalyst-Runtime.git] / lib / Catalyst / DispatchType / Chained.pm
index c22604b..d55d22d 100644 (file)
@@ -141,6 +141,10 @@ sub recurse_match {
         my @try_actions = @{$children->{$try_part}};
         TRY_ACTION: foreach my $action (@try_actions) {
             if (my $capture_attr = $action->attributes->{CaptureArgs}) {
+
+                # Short-circuit if not enough remaining parts
+                next TRY_ACTION unless @parts >= $capture_attr->[0];
+
                 my @captures;
                 my @parts = @parts; # localise
 
@@ -192,7 +196,11 @@ sub register {
         if ($parent eq '.') {
             $parent = '/'.$action->namespace;
         } elsif ($parent !~ m/^\//) {
-            $parent = '/'.join('/', $action->namespace, $parent);
+            if ($action->namespace) {
+                $parent = '/'.join('/', $action->namespace, $parent);
+            } else {
+                $parent = '/'.$parent; # special case namespace '' (root)
+            }
         }
     } else {
         $parent = '/'