X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FDispatchType%2FPath.pm;h=bff5f212f0cc37397265da4e7394d3fd77c2894b;hp=29c418ffdbad42f7e4afc42a838abb5ed826c75b;hb=5299fff8fe52a4f4c10698b258984e41a2f6964f;hpb=b9b89145c40b01ae04dc483f4f29c02cf08725be diff --git a/lib/Catalyst/DispatchType/Path.pm b/lib/Catalyst/DispatchType/Path.pm index 29c418f..bff5f21 100644 --- a/lib/Catalyst/DispatchType/Path.pm +++ b/lib/Catalyst/DispatchType/Path.pm @@ -48,7 +48,7 @@ Debug output for Path dispatch points sub list { my ( $self, $c ) = @_; my $column_width = Catalyst::Utils::term_width() - 35 - 9; - my $paths = Text::SimpleTable->new( + my $paths = Text::SimpleTable->new( [ 35, 'Path' ], [ $column_width, 'Private' ] ); foreach my $path ( sort keys %{ $self->_paths } ) { @@ -74,7 +74,9 @@ sub match { $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); @@ -114,8 +116,11 @@ sub register_path { $path =~ s!^/!!; $path = '/' unless length $path; $path = URI->new($path)->canonical; + $path =~ s{(?<=[^/])/+\z}{}; - unshift( @{ $self->_paths->{$path} ||= [] }, $action); + $self->_paths->{$path} = [ + sort { $a <=> $b } ($action, @{ $self->_paths->{$path} || [] }) + ]; return 1; } @@ -149,7 +154,7 @@ Catalyst Contributors, see Catalyst.pm =head1 COPYRIGHT -This program is free software, you can redistribute it and/or modify it under +This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself. =cut