-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Match optional parameter with / before the block no longer works #241
Comments
Hi @dannyvankooten , thank you for the modification, but it doesn't work with this example : $router->map('GET', '/archives/[lmin:category]?/page-[i:page]?', 'Article#archives');
|
Hi @PropreCity, Did that example use to work with AltoRouter < 2.0.0? It looks sensible to me that it doesn't work nowadays, so I'm wondering whether we should re-introduce this behavior in AltoRouter or change it to a custom regex (in your code) instead. |
Here's an example: $router->map('GET', '@/archives/?(?<category>[a-zA-Z]+)?/?(page-)?(?<page>\d+)?', 'Article#archives'); |
Hello @dannyvankooten, It doesn't work. But I think it isn't possible to make two parts optional with only one route declaration. I tried with this on FastRoute and it works : $router->get('/archives[/page-{page:\d+}]', 'Article#archives');
$router->get('/archives/{category:[a-z\-]+}[/page-{page:\d+}]', 'Article#archives'); But it doesn't work with AltoRouter : $router->get('/archives/page-[i:page]?', 'Article#archives');
$router->get('/archives/[lmin:category]/page-[i:page]?', 'Article#archives'); It works with |
Before version 2.0 of Altorouter, I could make "/" character optional, if it was before an optional block parameter.
It doesn't work anymore, the "/" is no longer an option. I can't access
/archives
, only/archives/
.In the documentation:
.[:format]? // Match an optional parameter 'format' - a / or . before the block is also optional
The text was updated successfully, but these errors were encountered: