Route with filename

Hallo Kirby-Friends,

I am currently working on a new version of my Podcast plugin. I am adding the ability to include piwik or google-analytics to get stats about downloads. For that I use a route like so:

'pattern' => '(:all)/download/(:all)',
'action'  => function($episode, $filename) { … }

It works great using an url like: myepisode/download/episode01

Unfortunately iTunes needs .mp3 as a file extension (or whatever the audio-format is), like:
myepisode/download/episode01.mp3

But as soon as I add .mp3 to the url, the route isn’t working anymore. Do I have to alter the pattern? I couldn’t figure out to get it working with a file extension in the url.

Thank you!
Maurice

Are you using the built in PHP server?

Why do you need the extension in the URL?

This happend to me as well.
regex for all seems right.

so maybe the router class is not escaping the dot char . to \. when creating the match string? thus the dot is treated as a regex expression and not a char?

In addition to the above: have you tried using (:any) instead of (:all) as a placeholder for the filename? Makes more sense in this context, I think.

Are you using the built in PHP server?
Why do you need the extension in the URL?

Yes, using the php server.
iTunes wants a file-extension in the url, it’s a bit annoying.

In addition to the above: have you tried using (:any) instead of (:all)

Yes, I tried that before, same result.

The old version of my plugin had the same problem, I used a htaccess rule, to remove the .mp3 from the url. But if it’s possible, I’d like to prevent to force the user to use htaccess oder similar to get the plugin working.

The built in PHP server does not support dots in URLs.

The built in PHP server does not support dots in URLs.

Ahhhhhhhh! So I’ve been debugging the wrong thing :wink: Thank you for your help!