From 8761a8ffbe3d120d0f4393dc0dbd3960f9991aaa Mon Sep 17 00:00:00 2001 From: Sebastian Riedel Date: Wed, 18 Nov 2015 03:26:36 +0100 Subject: [PATCH] no need to use a capturing group --- lib/Mojolicious/Guides/Routing.pod | 8 ++++---- lib/Mojolicious/Routes/Pattern.pm | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Mojolicious/Guides/Routing.pod b/lib/Mojolicious/Guides/Routing.pod index 6700cd34b6..da4a680d03 100644 --- a/lib/Mojolicious/Guides/Routing.pod +++ b/lib/Mojolicious/Guides/Routing.pod @@ -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 diff --git a/lib/Mojolicious/Routes/Pattern.pm b/lib/Mojolicious/Routes/Pattern.pm index 743f32e33c..a4112705c4 100644 --- a/lib/Mojolicious/Routes/Pattern.pm +++ b/lib/Mojolicious/Routes/Pattern.pm @@ -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; @@ -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 {