{"action":"opened","issue":{"url":"https://api.github.com/repos/zendframework/zend-expressive-fastroute/issues/15","repository_url":"https://api.github.com/repos/zendframework/zend-expressive-fastroute","labels_url":"https://api.github.com/repos/zendframework/zend-expressive-fastroute/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/zendframework/zend-expressive-fastroute/issues/15/comments","events_url":"https://api.github.com/repos/zendframework/zend-expressive-fastroute/issues/15/events","html_url":"https://github.com/zendframework/zend-expressive-fastroute/issues/15","id":151851640,"number":15,"title":"Optional elements are not taking into account on generate URI","user":{"login":"martinezdelariva","id":1567749,"avatar_url":"https://avatars.githubusercontent.com/u/1567749?v=3","gravatar_id":"","url":"https://api.github.com/users/martinezdelariva","html_url":"https://github.com/martinezdelariva","followers_url":"https://api.github.com/users/martinezdelariva/followers","following_url":"https://api.github.com/users/martinezdelariva/following{/other_user}","gists_url":"https://api.github.com/users/martinezdelariva/gists{/gist_id}","starred_url":"https://api.github.com/users/martinezdelariva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martinezdelariva/subscriptions","organizations_url":"https://api.github.com/users/martinezdelariva/orgs","repos_url":"https://api.github.com/users/martinezdelariva/repos","events_url":"https://api.github.com/users/martinezdelariva/events{/privacy}","received_events_url":"https://api.github.com/users/martinezdelariva/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-29T12:08:37Z","updated_at":"2016-04-29T12:08:37Z","closed_at":null,"body":"Hello,\r\n\r\nIt seems that the generation of a URI with optional suffix using FastRoute is not taking into account to remove the trailing `[, ]` when the optional parameter is given, and remove the whole element when is not provided:\r\n\r\nHow to reproduce in a Expressive application:\r\n\r\n```php\r\n// bootstrap $app using FastRoute as router\r\n\r\n$app->get('/users[/{id}]', function($request, $response, $out) use ($container) {\r\n    /** @var Zend\\Expressive\\Helper\\UrlHelper $helper */\r\n    $router = $container->get(Zend\\Expressive\\Router\\RouterInterface::class);\r\n\r\n    return new \\Zend\\Diactoros\\Response\\JsonResponse([\r\n        'uri'   => $router->generateUri('users'),\r\n        'uriId' => $router->generateUri('users', ['id' => 1234])\r\n    ]);\r\n\r\n}, 'users');\r\n\r\n// Output\r\n{\"uri\":\"/users[/{id}]\",\"uriId\":\"/users[/1234]\"}\r\n\r\n// Output expected\r\n{\"uri\":\"/users\",\"uriId\":\"/users/1234\"}\r\n```\r\n\r\nHow to reproduce in a naively way:\r\n\r\n```php\r\n$routerCollector = new FastRoute\\RouteCollector(\r\n    new FastRoute\\RouteParser\\Std(),\r\n    new FastRoute\\DataGenerator\\GroupCountBased()\r\n);\r\n$router = new Zend\\Expressive\\Router\\FastRouteRouter($routerCollector);\r\n$router->addRoute(\r\n    new Zend\\Expressive\\Router\\Route('/users[/{id}]', \r\n    function ($req, $res) {}, \r\n    ['GET'], \r\n    'users')\r\n);\r\n\r\necho $router->generateUri('users');\r\necho $router->generateUri('users', ['id' => 1234]);\r\n\r\n// Output:\r\n// /users[/{id}]\r\n// /users[/1234]\r\n\r\n// Output expected:\r\n// /users\r\n// /users/1234\r\n```\r\n\r\nThanks!"}}