symfony-cmf / routing-bundle

Symfony bundle to provide the CMF chain router to handle multiple routers, and the dynamic router to load routes from a database or other sources.
160 stars 78 forks source link

Routes trailing slash #464

Closed johndodev closed 3 years ago

johndodev commented 3 years ago

Hello,

Since 4.1, Symfony "automatically" handle trailing slash according to the route path (https://symfony.com/doc/4.1/routing.html#routing-trailing-slash-redirection).

I use cmf routing since a couple of days to declare dynamic routes with a RouteProvider, and it seems that functionality is not handle there, there is no redirection.

Do you think it is possible to add it in a next release ?

dbu commented 3 years ago

it makes sense to do this. however, the maintainers of this bundle are mainly keeping it up to date but not actively adding features. if you want to do it, i would be happy to review a merge request and then tag a release with the feature.

do you want to do a pull request for it? can you see where symfony does it? the cheap thing to do would be in https://github.com/symfony-cmf/Routing/blob/ea6fb2c7d56f4ab7f725888698db73f2bc6d3ae9/src/ChainRouter.php#L174 when we have no match to check if the requested path ends in / and if so try matching again without the /. that will allow all matchers to attempt to find a match. we would want the same logic as symfony core, i assume that they have a special case for / and maybe also for multiple slashes (like /path//).