From: Matt S Trout Date: Tue, 1 Nov 2005 04:59:06 +0000 (+0000) Subject: - Made relative regexps work X-Git-Tag: 5.7099_04~1065 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=ea5126a6c7f135eece1103e03432698134b29fac - Made relative regexps work --- diff --git a/lib/Catalyst/DispatchType/Regex.pm b/lib/Catalyst/DispatchType/Regex.pm index a1224c5..b906f69 100644 --- a/lib/Catalyst/DispatchType/Regex.pm +++ b/lib/Catalyst/DispatchType/Regex.pm @@ -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 diff --git a/t/live/lib/TestApp/Controller/Action/Regexp.pm b/t/live/lib/TestApp/Controller/Action/Regexp.pm index 8069f33..8bc04a7 100644 --- a/t/live/lib/TestApp/Controller/Action/Regexp.pm +++ b/t/live/lib/TestApp/Controller/Action/Regexp.pm @@ -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'); }