fixed bug with root alias

pull/534/head
Austin Collier 1 year ago
parent a3541a1f7a
commit aaf6a44a2c

@ -192,7 +192,9 @@ class Route
// catches potential optional parameter
$url = str_replace('(/', '/', $url);
// trim any trailing slashes
$url = rtrim($url, '/');
if($url !== '/') {
$url = rtrim($url, '/');
}
return $url;
}

@ -533,6 +533,13 @@ class RouterTest extends TestCase
$this->assertTrue($result);
}
public function testGetRootUrlByAlias()
{
$this->router->map('/', [$this, 'ok'], false, 'path1');
$url = $this->router->getUrlByAlias('path1');
$this->assertEquals('/', $url);
}
public function testGetUrlByAliasNoMatches()
{
$this->router->map('/path1', [$this, 'ok'], false, 'path1');

Loading…
Cancel
Save