- Made relative regexps work
Matt S Trout [Tue, 1 Nov 2005 04:59:06 +0000 (04:59 +0000)]
lib/Catalyst/DispatchType/Regex.pm
t/live/lib/TestApp/Controller/Action/Regexp.pm

index a1224c5..b906f69 100644 (file)
@@ -71,6 +71,9 @@ sub register {
     my $attrs = $action->attributes;
     my @register = map { @{ $_ || [] } } @{$attrs}{ 'Regex', 'Regexp' };
     foreach my $r (@register) {
+        unless ($r =~ /^\^/) {     # Relative regex
+            $r = '^'.$action->namespace.'/'.$r;
+        }
         $self->{paths}{$r} = $action;    # Register path for superclass
         push(
             @{ $self->{compiled} },      # and compiled regex for us
index 8069f33..8bc04a7 100644 (file)
@@ -8,7 +8,7 @@ sub one : Action Regex('^action/regexp/(\w+)/(\d+)$') {
     $c->forward('TestApp::View::Dump::Request');
 }
 
-sub two : Action Regexp('^action/regexp/(\d+)/(\w+)$') {
+sub two : Action Regexp('(\d+)/(\w+)$') {
     my ( $self, $c ) = @_;
     $c->forward('TestApp::View::Dump::Request');
 }