Skip to content

Commit

Permalink
[BUGFIX] Remove hostname of menu-item before matching
Browse files Browse the repository at this point in the history
Depending on its configuration, Dashboards use absolute urls, including the hostname.
For matching this hostname is being removed, always.

To be able to match dashboard URLs, the hostname of menu-item link URL is also removed, when given.

Relates: #6598
  • Loading branch information
a-r-m-i-n committed Jan 29, 2025
1 parent d8bb908 commit 3ed8821
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Menu/MenuItemMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,17 @@ private function doMarkSelectedPrettyUrlsMenuItem(array $menuItems, Request $req
$menuItemDto->setSubItems($this->doMarkSelectedPrettyUrlsMenuItem($subItems, $request));
}

if ($menuItemDto->getLinkUrl() === $normalizedCurrentUrl) {
// Remove host part from menu item link URL
$urlParts = parse_url($menuItemDto->getLinkUrl());
$linkUrlWithoutHost = $urlParts['path'];
if (\array_key_exists('query', $urlParts)) {
$linkUrlWithoutHost .= '?'.$urlParts['query'];
}
if (\array_key_exists('fragment', $urlParts)) {
$linkUrlWithoutHost .= '#'.$urlParts['fragment'];
}

if ($linkUrlWithoutHost === $normalizedCurrentUrl) {
$menuItemDto->setSelected(true);

return $menuItems;
Expand Down

0 comments on commit 3ed8821

Please sign in to comment.