Skip to content

Commit

Permalink
Merge pull request #11 from 0x62ash/master
Browse files Browse the repository at this point in the history
Fix array constraint
  • Loading branch information
Viacheslav Tykhanovskyi authored Aug 19, 2016
2 parents d86ebb6 + 57f306f commit e31bfef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Routes/Tiny/Pattern.pm
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ sub _prepare_pattern {
if (exists $self->{constraints}->{$name}) {
$constraint = $self->{constraints}->{$name};
if (ref $constraint eq 'ARRAY') {
$constraint = '?:' . join('|', @$constraint);
$constraint = join('|', @$constraint);
}
$re .= "($constraint)";
}
Expand Down
3 changes: 2 additions & 1 deletion t/match-with-constraints.t
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ subtest 'contraint as array' => sub {
constraints => {id => [qw/1 2 3/]}
);

ok $r->match('/articles/1');
ok $r->match('/articles/2');
is_deeply($r->match('/articles/2')->params, {id => 2});
ok !$r->match('/articles/a');

eval { $r->build_path('article', id => 'abc'); };
Expand Down

0 comments on commit e31bfef

Please sign in to comment.