Make UglyRouter compatible with routes with parameters (#399)
This commit is contained in:
parent
6ad0486468
commit
bf4a761d3a
2 changed files with 3 additions and 3 deletions
|
@ -55,7 +55,7 @@ class UglyRouter extends Router
|
||||||
*/
|
*/
|
||||||
public function pathFor($name, array $data = [], array $queryParams = []): string
|
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('');
|
$url = Uri::createFromString($this->relativePathFor($name, $data, $queryParams))->withPath('');
|
||||||
|
|
||||||
if ($this->basePath) {
|
if ($this->basePath) {
|
||||||
|
|
|
@ -79,7 +79,7 @@ class UglyRouterTest extends ContainerTest
|
||||||
public function testPathFor()
|
public function testPathFor()
|
||||||
{
|
{
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'/?page=foo',
|
'/?page=%2Ffoo',
|
||||||
$this->router->pathFor('foo', [], [])
|
$this->router->pathFor('foo', [], [])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ class UglyRouterTest extends ContainerTest
|
||||||
{
|
{
|
||||||
$this->router->setBasePath('/bar');
|
$this->router->setBasePath('/bar');
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'/bar/?page=foo',
|
'/bar/?page=%2Ffoo',
|
||||||
$this->router->pathFor('foo', [], [])
|
$this->router->pathFor('foo', [], [])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue