X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FDispatcher.pm;h=d038d9efd3d1b9a4938c999a4602804052f3a329;hb=cccc887d602aba1a3e47dcbd07620dafb07a61ad;hp=391fefcc25c34c0e0bb3666e13c3425942f2d9e6;hpb=e540158b361fd2c610c58fec1ee2608cfba61e51;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index 391fefc..d038d9e 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -286,12 +286,24 @@ returns a named action from a given namespace. sub get_action { my ( $self, $name, $namespace ) = @_; return unless $name; - $namespace ||= ''; - $namespace = '' if $namespace eq '/'; + + $namespace = join( "/", grep { length } split '/', $namespace || "" ); return $self->action_hash->{"$namespace/$name"}; } +=head2 $self->get_action_by_path( $path ); + +returns the named action by it's full path. + +=cut + +sub get_action_by_path { + my ( $self, $path ) = @_; + $path = "/$path" unless $path =~ /\//; + $self->action_hash->{$path}; +} + =head2 $self->get_actions( $c, $action, $namespace ) =cut @@ -299,8 +311,8 @@ sub get_action { sub get_actions { my ( $self, $c, $action, $namespace ) = @_; return [] unless $action; - $namespace ||= ''; - $namespace = '' if $namespace eq '/'; + + $namespace = join( "/", grep { length } split '/', $namespace || "" ); my @match = $self->get_containers($namespace);