NavigationItemForm: Don't bypass Url's own optimisations when saving urls

refs #12133
This commit is contained in:
Johannes Meyer 2016-11-03 14:31:47 +01:00
parent 4a791e6204
commit da2940a811
1 changed files with 4 additions and 2 deletions

View File

@ -99,8 +99,10 @@ class NavigationItemForm extends Form
$values = parent::getValues($suppressArrayNotation); $values = parent::getValues($suppressArrayNotation);
if (isset($values['url']) && $values['url']) { if (isset($values['url']) && $values['url']) {
$url = Url::fromPath($values['url']); $url = Url::fromPath($values['url']);
if (! $url->isExternal() && ($relativePath = $url->getRelativeUrl())) { if ($url->getBasePath() === $this->getRequest()->getBasePath()) {
$values['url'] = $relativePath; $values['url'] = $url->getRelativeUrl();
} else {
$values['url'] = $url->getAbsoluteUrl();
} }
} }