From caab707a171955ff2307251c5bc405493354bb8f Mon Sep 17 00:00:00 2001 From: Roman Date: Sat, 8 Jun 2024 11:07:48 +0200 Subject: [PATCH] minor bugfix --- Core/Objects/Router/Router.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Core/Objects/Router/Router.class.php b/Core/Objects/Router/Router.class.php index 6f90216..277bef3 100644 --- a/Core/Objects/Router/Router.class.php +++ b/Core/Objects/Router/Router.class.php @@ -41,7 +41,10 @@ class Router { } public function run(string $url, array &$pathParams): ?Route { - $this->requestedUri = $url; + // replace multiple leading slashes with one, otherwise parse_url() might interpret path as domain + // e.g. //index.php --> /index.php + $this->requestedUri = preg_replace("/^\/{2,}/", "/", $url); + $url = strtok($url, "?"); foreach ($this->routes as $route) { $match = $route->match($url);