walkor 2 years ago
parent
commit
5125dbbb6a
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/Protocols/Http/Request.php

+ 2 - 2
src/Protocols/Http/Request.php

@@ -234,8 +234,8 @@ class Request
     public function host(bool $withoutPort = false): ?string
     {
         $host = $this->header('host');
-        if ($host && $withoutPort && $pos = strpos($host, ':')) {
-            return substr($host, 0, $pos);
+        if ($host && $without_port) {
+            return preg_replace('/:\d{1,5}$/', '', $host);
         }
         return $host;
     }