Make UglyRouter compatible with routes with parameters (#399)

This commit is contained in:
Pierre Rudloff 2022-02-23 21:27:22 +01:00
parent 6ad0486468
commit bf4a761d3a
2 changed files with 3 additions and 3 deletions

View File

@ -55,7 +55,7 @@ class UglyRouter extends Router
*/
public function pathFor($name, array $data = [], array $queryParams = []): string
{
$queryParams['page'] = $name;
$queryParams['page'] = $this->relativePathFor($name, $data);
$url = Uri::createFromString($this->relativePathFor($name, $data, $queryParams))->withPath('');
if ($this->basePath) {

View File

@ -79,7 +79,7 @@ class UglyRouterTest extends ContainerTest
public function testPathFor()
{
$this->assertEquals(
'/?page=foo',
'/?page=%2Ffoo',
$this->router->pathFor('foo', [], [])
);
}
@ -93,7 +93,7 @@ class UglyRouterTest extends ContainerTest
{
$this->router->setBasePath('/bar');
$this->assertEquals(
'/bar/?page=foo',
'/bar/?page=%2Ffoo',
$this->router->pathFor('foo', [], [])
);
}