Url: Do not try to set attributes in method fromPath if not needed

refs #12133
This commit is contained in:
Noah Hilverling 2016-10-18 16:13:37 +02:00
parent b4aca4737b
commit 08719b0522
1 changed files with 17 additions and 14 deletions

View File

@ -214,6 +214,11 @@ class Url
if (isset($urlParts['fragment'])) { if (isset($urlParts['fragment'])) {
$urlObject->setAnchor($urlParts['fragment']); $urlObject->setAnchor($urlParts['fragment']);
} }
if (isset($urlParts['user']) || $urlObject->isExternal()) {
if (isset($urlParts['user'])) {
$urlObject->setUsername($urlParts['user']);
}
if (isset($urlParts['host'])) { if (isset($urlParts['host'])) {
$urlObject->setHost($urlParts['host']); $urlObject->setHost($urlParts['host']);
} }
@ -223,12 +228,10 @@ class Url
if (isset($urlParts['scheme'])) { if (isset($urlParts['scheme'])) {
$urlObject->setScheme($urlParts['scheme']); $urlObject->setScheme($urlParts['scheme']);
} }
if (isset($urlParts['user'])) {
$urlObject->setUsername($urlParts['user']);
}
if (isset($urlParts['pass'])) { if (isset($urlParts['pass'])) {
$urlObject->setPassword($urlParts['pass']); $urlObject->setPassword($urlParts['pass']);
} }
}
$urlObject->setParams($params); $urlObject->setParams($params);
return $urlObject; return $urlObject;