MDL-79118 output: account for empty node/current URL path element.

This commit is contained in:
Paul Holden
2023-08-22 17:55:43 +01:00
parent e998f14061
commit 9e68a02458
+5 -2
View File
@@ -194,12 +194,15 @@ class primary implements renderable, templatable {
$current = parse_url($FULLME ?? '');
$pathmatches = false;
// Exact match of the path of node and current url.
if ($nodeurl['path'] === $current['path']) {
$nodepath = $nodeurl['path'] ?? '/';
$currentpath = $current['path'] ?? '/';
if ($nodepath === $currentpath) {
$pathmatches = true;
}
// The current url may be trailed by a index.php, otherwise it's the same as the node path.
if (!$pathmatches && $nodeurl['path'] . 'index.php' === $current['path']) {
if (!$pathmatches && $nodepath . 'index.php' === $currentpath) {
$pathmatches = true;
}
// No path did match, so the node can't be active.