Merge pull request #534 from flightphp/alias-bug

fixed bug with root alias
pull/535/head v3.3.0
n0nag0n 1 year ago committed by GitHub
commit 19e40b9b8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -58,7 +58,7 @@
"test-coverage": "rm clover.xml && XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html=coverage --coverage-clover=clover.xml && vendor/bin/coverage-check clover.xml 100",
"lint": "phpstan --no-progress -cphpstan.neon",
"beautify": "phpcbf --standard=phpcs.xml",
"phpcs": "phpcs --standard=phpcs.xml"
"phpcs": "phpcs --standard=phpcs.xml -n"
},
"suggest": {
"latte/latte": "Latte template engine",

@ -192,7 +192,9 @@ class Route
// catches potential optional parameter
$url = str_replace('(/', '/', $url);
// trim any trailing slashes
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