From c57d2a49f2a781659a3e284525752d15bbccfb58 Mon Sep 17 00:00:00 2001 From: flashwave Date: Mon, 11 Sep 2023 19:25:12 +0000 Subject: [PATCH] Attempt to fix URL parsing edge case. --- VERSION | 2 +- src/Http/HttpRequest.php | 2 +- src/Routing/Route.php | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 860e4be..3a246b1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2309.80009 +0.2309.111925 diff --git a/src/Http/HttpRequest.php b/src/Http/HttpRequest.php index ec7c7d4..319c1c7 100644 --- a/src/Http/HttpRequest.php +++ b/src/Http/HttpRequest.php @@ -80,7 +80,7 @@ class HttpRequest extends HttpMessage { $build = new HttpRequestBuilder; $build->setHttpVersion(new Version(...array_map('intval', explode('.', substr($_SERVER['SERVER_PROTOCOL'], 5))))); $build->setMethod($_SERVER['REQUEST_METHOD']); - $build->setPath('/' . trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/')); + $build->setPath(parse_url('/' . trim($_SERVER['REQUEST_URI'], '/'), PHP_URL_PATH)); $build->setParams($_GET); $build->setCookies($_COOKIE); diff --git a/src/Routing/Route.php b/src/Routing/Route.php index fac985a..26fb6fd 100644 --- a/src/Routing/Route.php +++ b/src/Routing/Route.php @@ -16,7 +16,12 @@ class Route { private ?string $method; private string $path; - /** @internal */ + /** + * Creates a Route attribute. + * + * @param string $pathOrMethod Method name if this is registering a route, path if this is registering middleware. + * @param ?string $path Path if this registering a route, null if this is registering middleware. + */ public function __construct(string $pathOrMethod, ?string $path = null) { if($path === null) { $this->method = null;