From 882529c0a0da2bb9f76dcfbf03eb9569107289de Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 9 Jul 2023 23:13:27 -1000 Subject: [PATCH] Simplify FastUrlDispatcher resolve (#96234) --- homeassistant/components/http/__init__.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/homeassistant/components/http/__init__.py b/homeassistant/components/http/__init__.py index f559b09a1ff..68602e34d3e 100644 --- a/homeassistant/components/http/__init__.py +++ b/homeassistant/components/http/__init__.py @@ -600,7 +600,7 @@ class FastUrlDispatcher(UrlDispatcher): resource_index = self._resource_index # Walk the url parts looking for candidates - for i in range(len(url_parts), 1, -1): + for i in range(len(url_parts), 0, -1): url_part = "/" + "/".join(url_parts[1:i]) if (resource_candidates := resource_index.get(url_part)) is not None: for candidate in resource_candidates: @@ -608,11 +608,6 @@ class FastUrlDispatcher(UrlDispatcher): match_dict := (await candidate.resolve(request))[0] ) is not None: return match_dict - # Next try the index view if we don't have a match - if (index_view_candidates := resource_index.get("/")) is not None: - for candidate in index_view_candidates: - if (match_dict := (await candidate.resolve(request))[0]) is not None: - return match_dict # Finally, fallback to the linear search return await super().resolve(request)