Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed format regex generation bug in Mojolicious::Routes::Pattern
  • Loading branch information
kraih committed Dec 13, 2012
1 parent f0c9ecd commit e0fabd8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,9 +1,10 @@

3.66 2012-12-13
3.66 2012-12-14
- Added request_ok method to Test::Mojo.
- Improved documentation.
- Improved tests.
- Fixed multipart boundary detection bug in Mojo::Content.
- Fixed format regex generation bug in Mojolicious::Routes::Pattern.

3.65 2012-12-09
- Added upgrade method to Mojo::UserAgent::Transactor.
Expand Down
7 changes: 5 additions & 2 deletions lib/Mojolicious/Routes/Pattern.pm
Expand Up @@ -169,10 +169,13 @@ sub _compile_format {
# Default regex
my $c = $self->constraints;
return $self->format_regex(qr!\.([^/]+)$!)->format_regex
if !exists $c->{format} && $c->{format};
unless defined $c->{format};

# No regex
return undef unless $c->{format};

# Compile custom regex
my $regex = defined $c->{format} ? _compile_req($c->{format}) : '([^/]+)';
my $regex = _compile_req($c->{format});
return $self->format_regex(qr!\.$regex$!)->format_regex;
}

Expand Down
2 changes: 2 additions & 0 deletions t/mojolicious/pattern.t
Expand Up @@ -164,6 +164,8 @@ is $result->{action}, 'index', 'right value';
$pattern = Mojolicious::Routes::Pattern->new('/test', format => 0);
$pattern->defaults({action => 'index'});
$result = $pattern->match('/test', 1);
ok $pattern->regex, 'regex has been compiled on demand';
ok !$pattern->format_regex, 'no format regex';
is $result->{action}, 'index', 'right value';
is $result->{format}, undef, 'no value';
$result = $pattern->match('/test.xml', 1);
Expand Down

0 comments on commit e0fabd8

Please sign in to comment.