- Made :Path behave sanely at the root, hopefully
[catagits/Catalyst-Runtime.git] / lib / Catalyst / DispatchType / Path.pm
index 31f37b3..2cb950d 100644 (file)
@@ -62,7 +62,11 @@ sub register {
     my @register;
 
     foreach my $r ( @{ $attrs->{Path} || [] } ) {
-        unless ( $r =~ m!^/! ) {    # It's a relative path
+        unless ($r) {
+            $r = $action->namespace;
+            $r = '' if $r eq '/';
+        }
+        elsif ( $r !~ m!^/! ) {    # It's a relative path
             $r = $action->namespace . "/$r";
         }
         push( @register, $r );
@@ -78,10 +82,19 @@ sub register {
         # Register sub name as a relative path
     }
 
-    foreach my $r (@register) {
-        $r =~ s!^/!!;
-        $self->{paths}{$r} = $action;
-    }
+    $self->register_path( $c, $_, $action ) for @register;
+    return 1 if @register;
+    return 0;
+}
+
+=item $self->register_path($c, $path, $action)
+
+=cut
+
+sub register_path {
+    my ( $self, $c, $path, $action ) = @_;
+    $path =~ s!^/!!;
+    $self->{paths}{$path} = $action;
 }
 
 =back