Url: Build full urlString instead of path if username is set

refs #12133
This commit is contained in:
Noah Hilverling 2016-10-18 16:19:24 +02:00
parent a952a400ca
commit 3b6b0b8d4b
1 changed files with 21 additions and 18 deletions

View File

@ -586,28 +586,31 @@ class Url
} }
$basePath = $this->getBasePath(); $basePath = $this->getBasePath();
if (!$basePath) { if (! $basePath) {
$basePath = '/'; $basePath = '/';
} }
if (!$this->isExternal()) {
return $basePath . ($basePath !== '/' && $path ? '/' : '') . $path;
}
if ($this->getUsername() || $this->isExternal()) {
$urlString = ''; $urlString = '';
if ($this->getScheme()) { if ($this->getScheme()) {
$urlString = $urlString . $this->getScheme() . '://'; $urlString .= $this->getScheme() . '://';
} }
if ($this->getUsername() && $this->getPassword()) { if ($this->getPassword()) {
$urlString = $urlString . $this->getUsername() . ':' . $this->getPassword() . "@"; $urlString .= $this->getUsername() . ':' . $this->getPassword() . '@';
} elseif ($this->getUsername()) {
$urlString .= $this->getUsername() . '@';
} }
if ($this->getHost()) { if ($this->getHost()) {
$urlString = $urlString . $this->getHost(); $urlString .= $this->getHost();
} }
if ($this->getPort()) { if ($this->getPort()) {
$urlString = $urlString . $this->getPort(); $urlString .= ':' . $this->getPort();
} }
return $urlString . '/' . $path; return $urlString . '/' . $path;
} else {
return $basePath . ($basePath !== '/' && $path ? '/' : '') . $path;
}
} }
/** /**