From fff2d3c6419216ed635887bfaa336639fa9c5b08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20St=C3=B6ckl?= Date: Thu, 30 Mar 2023 12:02:03 +0200 Subject: [PATCH] feat. check if server vars are set, breaks unit tests otherwise --- src/Url.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Url.php b/src/Url.php index fb2b874..71e274a 100755 --- a/src/Url.php +++ b/src/Url.php @@ -53,7 +53,7 @@ public static function getCanonical(): string #[Pure] public static function getCurrent(): string { - return self::getHostUrl() . $_SERVER['REQUEST_URI']; + return self::getHostUrl() . ($_SERVER['REQUEST_URI'] ?? ""); } /** @@ -62,7 +62,7 @@ public static function getCurrent(): string #[Pure] public static function getHostUrl(): string { - return "http" . (self::isSecure() ? "s" : "") . "://" . $_SERVER['HTTP_HOST']; + return "http" . (self::isSecure() ? "s" : "") . "://" . ($_SERVER['HTTP_HOST'] ?? ""); } /** @@ -72,7 +72,7 @@ public static function getHostUrl(): string */ public static function isSecure(): bool { - return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] === 443; + return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || (isset($_SERVER["SERVER_PORT"]) && $_SERVER['SERVER_PORT'] === 443); } /**