Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

modified to allow to use extended regexp (?:including ":" - colon) as…

… pattern
  • Loading branch information...
commit 8b0f5ada003ecc44bef57f20237db718ab68a2c0 1 parent ecdb779
nipotan authored
Showing with 22 additions and 1 deletion.
  1. +1 −1  lib/Router/Simple/Route.pm
  2. +21 −0 t/11_ext_regexp.t
View
2  lib/Router/Simple/Route.pm
@@ -48,7 +48,7 @@ sub new {
([^{:*]+) # normal string
!
if ($1) {
- my ($name, $pattern) = split /:/, $1;
+ my ($name, $pattern) = split /:/, $1, 2;
push @capture, $name;
$pattern ? "($pattern)" : "([^/]+)";
} elsif ($2) {
View
21 t/11_ext_regexp.t
@@ -0,0 +1,21 @@
+use strict;
+use warnings;
+use Router::Simple;
+use Test::More;
+
+my $r = Router::Simple->new();
+$r->connect('/blog/{year:(?:199\d|20\d{2})}/{month:(?:0?[1-9]|1[0-2])}' => {controller => 'Root', action => 'monthly'});
+
+is_deeply(
+ $r->match('/blog/2010/08'),
+ {
+ controller => 'Root',
+ action => 'monthly',
+ year => '2010',
+ month => '08',
+ }
+);
+is($r->match('/blog/1989/08'), undef, "strictly regexp check #1");
+is($r->match('/blog/2010/13'), undef, "strictly regexp check #2");
+
+done_testing;
Please sign in to comment.
Something went wrong with that request. Please try again.