X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FDispatchType%2FPath.pm;h=bd74c79d6190ecf173687a7069eed41a2030bdfb;hb=1627551a60fe1e220d390a565f793dea27cd36a6;hp=227815f04360ab47f04448ed2c5cd040656dae91;hpb=0ba80bce27a56d366c8d44c254332dd83f9ba0f9;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/DispatchType/Path.pm b/lib/Catalyst/DispatchType/Path.pm index 227815f..bd74c79 100644 --- a/lib/Catalyst/DispatchType/Path.pm +++ b/lib/Catalyst/DispatchType/Path.pm @@ -3,6 +3,7 @@ package Catalyst::DispatchType::Path; use strict; use base qw/Catalyst::DispatchType/; use Text::SimpleTable; +use URI; =head1 NAME @@ -41,6 +42,7 @@ sub match { $path ||= '/'; if ( my $action = $self->{paths}->{$path} ) { + return 0 unless $action->match($c); $c->req->action($path); $c->req->match($path); $c->action($action); @@ -58,31 +60,10 @@ sub match { sub register { my ( $self, $c, $action ) = @_; - my $attrs = $action->attributes; - my @register; - - foreach my $r ( @{ $attrs->{Path} || [] } ) { - unless ($r) { - $r = $action->namespace; - $r = '/' unless length $r; - } - elsif ( $r !~ m!^/! ) { # It's a relative path - $r = $action->namespace . "/$r"; - } - push( @register, $r ); - } - - if ( $attrs->{Global} || $attrs->{Absolute} ) { - push( @register, $action->name ); # Register sub name against root - } - - if ( $attrs->{Local} || $attrs->{Relative} ) { - push( @register, join( '/', $action->namespace, $action->name ) ); - - # Register sub name as a relative path - } + my @register = @{ $action->attributes->{Path} || [] }; $self->register_path( $c, $_, $action ) for @register; + return 1 if @register; return 0; } @@ -95,6 +76,8 @@ sub register_path { my ( $self, $c, $path, $action ) = @_; $path =~ s!^/!!; $path = '/' unless length $path; + $path = URI->new($path)->canonical; + $self->{paths}{$path} = $action; }