diff --git a/src/Pecee/Http/Request.php b/src/Pecee/Http/Request.php index 100cd38..a09956a 100644 --- a/src/Pecee/Http/Request.php +++ b/src/Pecee/Http/Request.php @@ -405,6 +405,11 @@ public function setUrl(Url $url): void */ public function setHost(?string $host): void { + // Strip any potential ports from hostname + if (strpos($host, ':') !== false) { + $host = strstr($host, strrchr($host, ':'), true); + } + $this->host = $host; } diff --git a/src/Pecee/Http/Url.php b/src/Pecee/Http/Url.php index 9ba71ac..4bd2647 100644 --- a/src/Pecee/Http/Url.php +++ b/src/Pecee/Http/Url.php @@ -164,11 +164,6 @@ public function getHost(bool $includeTrails = false): ?string */ public function setHost(string $host): self { - // Strip any potential ports from hostname - if (strpos($host, ':') !== false) { - $host = strstr($host, strrchr($host, ':'), true); - } - $this->host = $host; return $this;