{"action":"created","issue":{"url":"https://api.github.com/repos/slimphp/Slim/issues/1679","labels_url":"https://api.github.com/repos/slimphp/Slim/issues/1679/labels{/name}","comments_url":"https://api.github.com/repos/slimphp/Slim/issues/1679/comments","events_url":"https://api.github.com/repos/slimphp/Slim/issues/1679/events","html_url":"https://github.com/slimphp/Slim/issues/1679","id":122411479,"number":1679,"title":"Routing bug?","user":{"login":"feryardiant","id":508665,"avatar_url":"https://avatars.githubusercontent.com/u/508665?v=3","gravatar_id":"","url":"https://api.github.com/users/feryardiant","html_url":"https://github.com/feryardiant","followers_url":"https://api.github.com/users/feryardiant/followers","following_url":"https://api.github.com/users/feryardiant/following{/other_user}","gists_url":"https://api.github.com/users/feryardiant/gists{/gist_id}","starred_url":"https://api.github.com/users/feryardiant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/feryardiant/subscriptions","organizations_url":"https://api.github.com/users/feryardiant/orgs","repos_url":"https://api.github.com/users/feryardiant/repos","events_url":"https://api.github.com/users/feryardiant/events{/privacy}","received_events_url":"https://api.github.com/users/feryardiant/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-12-16T02:11:35Z","updated_at":"2015-12-16T16:26:21Z","closed_at":null,"body":"Here I have setup my [`routes.php`](https://github.com/projek-xyz/slim-skeleton/blob/develop/app/routers.php)\r\n\r\n```php\r\n$app->get('/[{name}]', 'App\\Actions\\HomeAction:index')->setName('home-page');\r\n```\r\n\r\nand here my index method in [action class](https://github.com/projek-xyz/slim-skeleton/blob/develop/app/src/Actions/HomeAction.php)\r\n\r\n```php\r\npublic function index($req, $res, $args)\r\n{\r\n    if (isset($args['name'])) {\r\n        return $this->view->render('hello', [\r\n            'name' => $args['name'],\r\n            'desc' => 'Welcome to world',\r\n        ]);\r\n    }\r\n    return $this->view->render('home');\r\n}\r\n```\r\n\r\nand sure it works as expected\r\n\r\n| Request URI | Response |\r\n| --------------- | ----------------- | \r\n| `example.com[/]` | render `home` template | \r\n| `example.com/foobar` | render `hallo` template, with `$args['name'] = 'foobar'` |\r\n| `example.com/foo/bar` | return not found |\r\n\r\nbut I don't expect it could work like this.\r\n\r\n| Request URI | Response |\r\n| --------------- | ----------------- | \r\n| `example.com//` | render `home` template |\r\n| `example.com//foo` | render `home` template |\r\n| `example.com//foo/bar` | render `hallo` template, with `$args['name'] = 'bar'` |\r\n| `example.com//foo/bar/bas` | return not found |\r\n| `example.com///foo` | render `home` template | \r\n| `example.com///foo/bar` | render `home` template |\r\n| `example.com///foo/bar/bas` | render `home` template |\r\n\r\nIs it a bug?\r\n\r\n**EDIT**: I'm using local ubuntu server with nginx"},"comment":{"url":"https://api.github.com/repos/slimphp/Slim/issues/comments/165164626","html_url":"https://github.com/slimphp/Slim/issues/1679#issuecomment-165164626","issue_url":"https://api.github.com/repos/slimphp/Slim/issues/1679","id":165164626,"user":{"login":"geggleto","id":4027602,"avatar_url":"https://avatars.githubusercontent.com/u/4027602?v=3","gravatar_id":"","url":"https://api.github.com/users/geggleto","html_url":"https://github.com/geggleto","followers_url":"https://api.github.com/users/geggleto/followers","following_url":"https://api.github.com/users/geggleto/following{/other_user}","gists_url":"https://api.github.com/users/geggleto/gists{/gist_id}","starred_url":"https://api.github.com/users/geggleto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geggleto/subscriptions","organizations_url":"https://api.github.com/users/geggleto/orgs","repos_url":"https://api.github.com/users/geggleto/repos","events_url":"https://api.github.com/users/geggleto/events{/privacy}","received_events_url":"https://api.github.com/users/geggleto/received_events","type":"User","site_admin":false},"created_at":"2015-12-16T16:26:21Z","updated_at":"2015-12-16T16:26:21Z","body":"This is not a bug and is documented in FastRoute.\r\n\r\nFrom the README.md of FastRoute\r\n```\r\n// Matches /user/foobar, but not /user/foo/bar\r\n$r->addRoute('GET', '/user/{name}', 'handler');\r\n\r\n// Matches /user/foo/bar as well\r\n$r->addRoute('GET', '/user/{name:.+}', 'handler');\r\n```\r\nThe correct pattern would be...\r\n$app->get('/[{name:.+}]', 'App\\Actions\\HomeAction:index')->setName('home-page');\r\n\r\nexample.com// ==> home\r\nexample.com//foo ==> hallo \r\nexample.com//foo/bar => matches because of the .+\r\nexample.com//foo/bar/bas => matches because of the .+\r\nexample.com///foo => hallo\r\nexample.com///foo/bar =>   matches because of the .+\r\nexample.com///foo/bar/bas =>  matches because of the .+\r\n\r\nI am not a regex wizard. But there would be a regex possible I think to do exactly what he wants."}}