Home > Net >  Mojolicious API is disregarding the characters after " . " in the URL argument
Mojolicious API is disregarding the characters after " . " in the URL argument

Time:09-17

I have defined the following route in my code:

my $route = $r->any('/api')->to('API#');
$route->get('/get_data/:filename')->to('#submit_forms');

if the filename that I pass into the url is "foo123456.bar_baz.bz2", when I print the argument, I get: (for example http://example.com/api/get_data/foo123456.bar_baz.bz2

print Dumper($c->param('filename'));
# foo123456

Why is it cutting everything after the period?

CodePudding user response:

Use # (or *) instead of : for your placeholder:

$route->get('/get_data/#filename')->to('#submit_forms');

Mojolicious has 3 kinds of placeholders:

Quoting the documentation of relaxed placeholders:

They can be especially useful for manually matching file names with extensions

  • Related