diff --git a/src/Http/Url.php b/src/Http/Url.php index 716e356a..6783e350 100644 --- a/src/Http/Url.php +++ b/src/Http/Url.php @@ -324,7 +324,7 @@ public function getAuthority(): string public function getHostUrl(): string { return ($this->scheme ? $this->scheme . ':' : '') - . (($authority = $this->getAuthority()) ? '//' . $authority : ''); + . (($authority = $this->getAuthority()) !== '' ? '//' . $authority : ''); } diff --git a/src/Http/UrlImmutable.php b/src/Http/UrlImmutable.php index 85d64f87..b65c239c 100644 --- a/src/Http/UrlImmutable.php +++ b/src/Http/UrlImmutable.php @@ -281,7 +281,7 @@ public function getAuthority(): string public function getHostUrl(): string { return ($this->scheme ? $this->scheme . ':' : '') - . ($this->authority ? '//' . $this->authority : ''); + . ($this->authority !== '' ? '//' . $this->authority : ''); } diff --git a/tests/Http/Url.httpScheme.phpt b/tests/Http/Url.httpScheme.phpt index 62dac7d6..04c356ef 100644 --- a/tests/Http/Url.httpScheme.phpt +++ b/tests/Http/Url.httpScheme.phpt @@ -55,3 +55,6 @@ Assert::same('?arg=value#anchor', $url->absoluteUrl); $url->setPath(''); Assert::same('', $url->getPath()); + +$url = new Url('https://0/0'); +Assert::same('https://0', $url->hostUrl); diff --git a/tests/Http/UrlImmutable.Url.phpt b/tests/Http/UrlImmutable.Url.phpt index 30149f99..9471eb18 100644 --- a/tests/Http/UrlImmutable.Url.phpt +++ b/tests/Http/UrlImmutable.Url.phpt @@ -32,3 +32,6 @@ Assert::same('anchor', $url->fragment); Assert::same('username%3A:password%3A@hostname:60', $url->authority); Assert::same('http://username%3A:password%3A@hostname:60', $url->hostUrl); Assert::same('http://username%3A:password%3A@hostname:60/p%61th/script.php?arg=value#anchor', $url->absoluteUrl); + +$url = new UrlImmutable('https://0/0'); +Assert::same('https://0', $url->hostUrl);