$path = '/' if !defined $path || !length $path;
- foreach my $action ( @{ $self->_paths->{$path} || [] } ) {
+ my @actions = @{ $self->_paths->{$path} || [] };
+
+ foreach my $action ( @actions ) {
next unless $action->match($c);
$c->req->action($path);
$c->req->match($path);
$path =~ s!^/!!;
$path = '/' unless length $path;
$path = URI->new($path)->canonical;
+ $path =~ s{(?<=[^/])/+\z}{};
- unshift( @{ $self->_paths->{$path} ||= [] }, $action);
-
- $self->_paths->{$path} = [ sort @{ $self->_paths->{$path} } ];
+ $self->_paths->{$path} = [
+ sort { $a->compare($b) } ($action, @{ $self->_paths->{$path} || [] })
+ ];
return 1;
}