walkor 2 年之前
父節點
當前提交
5125dbbb6a
共有 1 個文件被更改,包括 2 次插入2 次删除
  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;
     }