D1 => D2 Regex route is not anchored any more
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
There are two issues open for going over this part. I hope to have them resolved this week to cover all cases. It makes sense to anchor them, but I believe we found an issue which made us change it. Should dig through the Git history when doing this. On Mon, Dec 15, 2014 at 10:02 AM, Gabor Szabo <gabor@szabgab.com> wrote:
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
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
participants (2)
-
Gabor Szabo -
Sawyer X