From 1f8f34b7de6a6191d6066e532ee2179c28d5eee1 Mon Sep 17 00:00:00 2001 From: Dominik George Date: Mon, 16 Nov 2020 23:22:02 +0100 Subject: [PATCH] Anchor related_url to beginning of request path Closes #22. --- menu_generator/menu.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/menu_generator/menu.py b/menu_generator/menu.py index 276d76e..f20d0d3 100755 --- a/menu_generator/menu.py +++ b/menu_generator/menu.py @@ -91,14 +91,14 @@ def _is_selected(self, item_dict): If related URLS are given, it also returns true if one of the related URLS is part of path. """ url = self._get_url(item_dict) - if self._is_root(item_dict) and url in self.path: + if self._is_root(item_dict) and self.path.startswith(url): return True elif url == self.path: return True else: # Go through all related URLs and test for related_url in self._get_related_urls(item_dict): - if related_url in self.path: + if self.path.startswith(related_url): return True return False