Url: Add username and password to method getBaseUrl

refs #12133
This commit is contained in:
Noah Hilverling 2016-10-18 16:16:13 +02:00
parent 9fcc39e0ba
commit a952a400ca
1 changed files with 18 additions and 2 deletions

View File

@ -410,11 +410,27 @@ class Url
*/
public function getBaseUrl()
{
if (!$this->isExternal()) {
if (! $this->isExternal()) {
return $this->getBasePath();
}
return $this->getScheme() . '://' . $this->getHost() . ($this->getPort() ? (':' . $this->getPort()) : '');
$urlString = '';
if ($this->getScheme()) {
$urlString .= $this->getScheme() . '://';
}
if ($this->getPassword()) {
$urlString .= $this->getUsername() . ':' . $this->getPassword() . '@';
} elseif ($this->getUsername()) {
$urlString .= $this->getUsername() . '@';
}
if ($this->getHost()) {
$urlString .= $this->getHost();
}
if ($this->getPort()) {
$urlString .= ':' . $this->getPort();
}
return $urlString;
}
/**