From c110825140cd4ca190dde2420b674d7331206300 Mon Sep 17 00:00:00 2001 From: Johannes Kantz <67144859+JohannesKantz@users.noreply.github.com> Date: Sat, 21 Jan 2023 13:49:59 +0100 Subject: [PATCH] fix: ignore trailing / at the end of uri --- Router/Router.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Router/Router.php b/Router/Router.php index 6e5b7a3..edf7c2f 100644 --- a/Router/Router.php +++ b/Router/Router.php @@ -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 = [];