fix stackoverflow Path bug
[catagits/Catalyst-Runtime.git] / lib / Catalyst / DispatchType / Path.pm
index f792fc5..6687326 100644 (file)
@@ -31,7 +31,7 @@ dispatch types, see:
 
 =over 4
 
-=item * L<Catalyst::Manual::Intro> for how they affect website authors
+=item * L<Catalyst::Manual::Intro> for how they affect application authors
 
 =item * L<Catalyst::DispatchType> for implementation information.
 
@@ -74,7 +74,12 @@ sub match {
 
     $path = '/' if !defined $path || !length $path;
 
-    foreach my $action ( @{ $self->_paths->{$path} || [] } ) {
+    # sort from least args to most
+    my @actions = sort { ($b->attributes->{Args}||0) <=>
+                      ($a->attributes->{Args}||0) }
+            @{ $self->_paths->{$path} || [] };
+
+    foreach my $action ( @actions ) {
         next unless $action->match($c);
         $c->req->action($path);
         $c->req->match($path);