diff --git a/src/Http/Url.php b/src/Http/Url.php index 80a88b26..1ea48d1f 100644 --- a/src/Http/Url.php +++ b/src/Http/Url.php @@ -376,7 +376,8 @@ public function getAuthority() */ public function getHostUrl() { - return ($this->scheme ? $this->scheme . ':' : '') . '//' . $this->getAuthority(); + return ($this->scheme ? $this->scheme . ':' : '') + . (($authority = $this->getAuthority()) || $this->scheme ? '//' . $authority : ''); } diff --git a/tests/Http/Url.httpScheme.phpt b/tests/Http/Url.httpScheme.phpt index 8016cbc1..5cd6a37f 100644 --- a/tests/Http/Url.httpScheme.phpt +++ b/tests/Http/Url.httpScheme.phpt @@ -49,7 +49,7 @@ $url->setPath(''); Assert::same('/', $url->getPath()); $url->setHost('')->setPath(''); -Assert::same('//?arg=value#anchor', $url->absoluteUrl); +Assert::same('?arg=value#anchor', $url->absoluteUrl); $url->setPath(''); Assert::same('', $url->getPath());