Make sure generated names don't have two slashes in a row
[catagits/CatalystX-Routes.git] / lib / CatalystX / Routes.pm
index bd9a131..9363f1d 100644 (file)
@@ -48,10 +48,13 @@ sub _add_route {
         $attrs->{Chained} = q{/};
     }
 
+    my $name = $_[0];
+    $name =~ s{^/}{};
+
     # We need to turn the full chain name into a path, since two end points
     # from two different chains could have the same end point name.
-    ( my $name = ( $attrs->{Chained} eq '/' ? q{} : $attrs->{Chained} ) . q{/}
-            . $_[0] ) =~ s/(\W)/'X' . sprintf( '%x', ord($1) )/eg;
+    $name = ( $attrs->{Chained} eq '/' ? q{} : $attrs->{Chained} ) . q{/}
+        . $name;
 
     my $meth_base = '__route__' . $name;
 
@@ -74,7 +77,7 @@ sub _add_chain_point {
     my $meta = shift;
     my ( $attrs, $sub ) = _process_args( $meta, @_ );
 
-    ( my $name = $_[0] ) =~ s/(\W)/'X' . sprintf('%x', ord(1) )/eg;
+    my $name = $_[0];
 
     $meta->add_chain_point( $name => [ $attrs, $sub ] );
 }
@@ -321,6 +324,9 @@ is essentially ignored (but still required).
 Note that it is legitimate to pass the empty string as the name for a chain's
 end point.
 
+If the end point's name does not start with a slash, it will be prefixed with
+the controller's namespace.
+
 If you don't specify a C<chained> value for an end point, then it will use the
 root URI, C</>, as the root of the chain.