Slim: Routing bug?
Here I have setup my routes.php
$app->get('/[{name}]', 'App\Actions\HomeAction:index')->setName('home-page');
and here my index method in action class
public function index($req, $res, $args)
{
if (isset($args['name'])) {
return $this->view->render('hello', [
'name' => $args['name'],
'desc' => 'Welcome to world',
]);
}
return $this->view->render('home');
}
and sure it works as expected
| Request URI | Response |
|---|---|
example.com[/] |
render home template |
example.com/foobar |
render hallo template, with $args['name'] = 'foobar' |
example.com/foo/bar |
return not found |
but I don’t expect it could work like this.
| Request URI | Response |
|---|---|
example.com// |
render home template |
example.com//foo |
render home template |
example.com//foo/bar |
render hallo template, with $args['name'] = 'bar' |
example.com//foo/bar/bas |
return not found |
example.com///foo |
render home template |
example.com///foo/bar |
render home template |
example.com///foo/bar/bas |
render home template |
Is it a bug?
EDIT: I’m using local ubuntu server with nginx
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 16 (16 by maintainers)
haha…
This function is intended specifically for the purpose of parsing URLs and not URIs.That documentation snippet explains where we got the idea to use
parse_url()!However, the documentation for parse_url says:
I’m pretty sure that using
parse_urlis wrong in this case and this line should be:Thoughts @codeguy, @silentworks?