Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Inconsistent results trying to use parameters in prefix #966

sapphirecat opened this Issue · 1 comment

2 participants


Starting from Dancer 1.3118 and running dancer -a foo, then writing in foo/lib/

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/ 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.


At the moment the prefix can only be a string. I must say, though, it would be quite handy if it could hold parameters or be a regex, just like the regular route argument. Hmmm.... I'll see what I can do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.