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=c13f73c0eadbfbab058165c1e144af0256e3a1bb;hp=ac28382976e48d63656a0165ecaf0ddb3728f0f7;hb=ea0e58d9d85d93bf94c3ffa6b4d7b71b200bbdf1;hpb=2a5635138b6600a5fb2bf1b7d040d32582eddd24 diff --git a/lib/Catalyst/DispatchType/Path.pm b/lib/Catalyst/DispatchType/Path.pm index ac28382..c13f73c 100644 --- a/lib/Catalyst/DispatchType/Path.pm +++ b/lib/Catalyst/DispatchType/Path.pm @@ -93,6 +93,29 @@ sub register_path { return 1; } +=head2 $self->uri_for_action($action, $captures) + +get a URI part for an action; always returns undef is $captures is set +since Path actions don't have captures + +=cut + +sub uri_for_action { + my ( $self, $action, $captures ) = @_; + + return undef if @$captures; + + if (my $paths = $action->attributes->{Path}) { + my $path = $paths->[0]; + $path = '/' unless length($path); + $path = "/${path}" unless ($path =~ m/^\//); + $path = URI->new($path)->canonical; + return $path; + } else { + return undef; + } +} + =head1 AUTHOR Matt S Trout