Navigation Menu

Skip to content

Commit

Permalink
no need to use a capturing group
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 18, 2015
1 parent c9b6598 commit 8761a8f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/Mojolicious/Guides/Routing.pod
Expand Up @@ -787,10 +787,10 @@ to list all available routes together with name and underlying regular
expressions.

$ ./myapp.pl routes -v
/foo/:name .... POST fooname (^\/foo/([^/.]+)/?(?:\.([^/]+))?$)
/bar ..U. * bar (^\/bar)
+/baz ...W GET baz (^\/baz/?(?:\.([^/]+))?$)
/yada .... * yada (^\/yada/?(?:\.([^/]+))?$)
/foo/:name .... POST fooname ^\/foo/([^/.]+)/?(?:\.([^/]+))?$
/bar ..U. * bar ^\/bar
+/baz ...W GET baz ^\/baz/?(?:\.([^/]+))?$
/yada .... * yada ^\/yada/?(?:\.([^/]+))?$

=head1 ADVANCED

Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Routes/Pattern.pm
Expand Up @@ -33,7 +33,7 @@ sub match_partial {
# Path
return undef unless my @captures = $$pathref =~ $self->regex;
$$pathref = ${^POSTMATCH};
shift @captures;
@captures = () if $#+ == 0;
my $captures = {%{$self->defaults}};
for my $placeholder (@{$self->placeholders}, 'format') {
last unless @captures;
Expand Down Expand Up @@ -142,7 +142,7 @@ sub _compile {
$regex .= _compile_format($constraints->{format}, $defaults->{format})
if $detect;

$self->regex(qr/(^$regex)/ps);
$self->regex(qr/^$regex/ps);
}

sub _compile_format {
Expand Down

0 comments on commit 8761a8f

Please sign in to comment.