Description
Starting from Dancer 1.3118 and running dancer -a foo
, then writing in foo/lib/foo.pm
:
prefix '/:client' => sub {
get '/' => sub {
template 'index';
};
get '/tickets' => sub {
template 'index';
};
};
The second route can be reached via /MegaCorp/tickets
but the first cannot be reached via /MegaCorp
--in fact, it is only reachable by /:client
; otherwise a 404 is generated because this fails to get the route:
[5014] core @0.000516> [hit #4]Trying to match 'GET /MegaCorp' against /(?-xism:^(?-xism:^\/\:client(?:\/)?$)$)/ (generated from '(?-xism:^\/\:client(?:\/)?$)') in /usr/local/share/perl5/Dancer/Route.pm l. 84
It looks like this happens because Dancer::Route::_init_prefix
wants to match the "/" pattern with or without the trailing slash, builds a regexp to do so, and sets it; later, _build_regexp
sees that it already has a regexp, sets it as the compiled regexp, and does not actually parse the parameters from the string. When a pattern isn't "/", then a non-regexp route will end up in _build_regexp_from_string
, which is called with the concatenation of prefix and pattern, and thus parses parameters anywhere in the string.
I haven't been able to find in the documentation any explicit confirmation/denial of whether the prefix is intended to be capable of holding parameters.