From c89323d6fe54d64aeb254cf75ac916cedad762d8 Mon Sep 17 00:00:00 2001 From: l0gicgate Date: Mon, 6 May 2019 11:30:42 -0600 Subject: [PATCH] fix UriFactory host detection logic --- src/Factory/UriFactory.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Factory/UriFactory.php b/src/Factory/UriFactory.php index 00f4817..7d6e2c8 100644 --- a/src/Factory/UriFactory.php +++ b/src/Factory/UriFactory.php @@ -59,14 +59,15 @@ public function createFromGlobals(array $globals): Uri $password = isset($globals['PHP_AUTH_PW']) ? $globals['PHP_AUTH_PW'] : ''; // Authority: Host + $host = ''; if (isset($globals['HTTP_HOST'])) { - $host = $globals['HTTP_HOST'] ?: ''; - } else { - $host = $globals['SERVER_NAME'] ?: ''; + $host = $globals['HTTP_HOST']; + } elseif (isset($globals['SERVER_NAME'])) { + $host = $globals['SERVER_NAME']; } // Authority: Port - $port = isset($globals['SERVER_PORT']) && !empty($globals['SERVER_PORT']) ? (int) $globals['SERVER_PORT'] : 80; + $port = !empty($globals['SERVER_PORT']) ? (int) $globals['SERVER_PORT'] : 80; if (preg_match('/^(\[[a-fA-F0-9:.]+\])(:\d+)?\z/', $host, $matches)) { $host = $matches[1];