fix: ignore trailing / at the end of uri

This commit is contained in:
Johannes Kantz 2023-01-21 13:49:59 +01:00
parent 1034dd30f9
commit c110825140

View File

@ -20,8 +20,9 @@ class Router
*/
public function __construct(string $pathname)
{
$this->uri = is_countable($_SERVER['REQUEST_URI']) && count($_SERVER['REQUEST_URI']) > 1 ? rtrim($_SERVER['REQUEST_URI'], "/") : $_SERVER['REQUEST_URI'];
$this->uri = str_replace($pathname, "", $this->uri);
$this->uri = str_replace($pathname, "", $_SERVER['REQUEST_URI']);
$this->uri = strlen($this->uri) > 1 ? rtrim($this->uri, "/") : $this->uri;
$this->requestType = $_SERVER['REQUEST_METHOD'];
$this->routes = [];
$this->middleware = [];