[dancer-users] D1 => D2 Regex route is not anchored any more

Gabor Szabo gabor at szabgab.com
Mon Dec 15 09:02:28 GMT 2014


I just found an issue with my D1 => D2 migration that broke the Perl Maven
site.
I think I managed to fix it but I'd like to clarify this:

I used to have a route handler like this:

get qr{/pro/(.*)} => sub {

    my ($path) = splat;

    return $path;

};
In D1 this was matching only routes that started with /pro
As if there was an implicit ^ at the beginning of the route.

Now, in D2, it will match anywhere so it started to match URLs such as
/media/pro/file

I could fix this by adding an explicit caret to the beginning of the regex:

get qr{^/pro/(.*)} => sub {

    my ($path) = splat;

    return $path;

};

Please confirm if this is really the case or if I just had some other
issues?
I think this should be added to the migration document with the recommended
solution.

Could I have solved this with the "prefix" keyword? How? Would that be
better?

regards
    Gabor




-- 
Gabor Szabo                     http://szabgab.com/
Perl Maven                       http://perlmaven.com/
Perl Weekly                       http://perlweekly.com/
Phone:                             +972-54-4624648
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20141215/87fab66a/attachment.html>


More information about the dancer-users mailing list