mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Simplify FastUrlDispatcher resolve (#96234)
This commit is contained in:
parent
fa6d659f2b
commit
882529c0a0
@ -600,7 +600,7 @@ class FastUrlDispatcher(UrlDispatcher):
|
|||||||
resource_index = self._resource_index
|
resource_index = self._resource_index
|
||||||
|
|
||||||
# Walk the url parts looking for candidates
|
# 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])
|
url_part = "/" + "/".join(url_parts[1:i])
|
||||||
if (resource_candidates := resource_index.get(url_part)) is not None:
|
if (resource_candidates := resource_index.get(url_part)) is not None:
|
||||||
for candidate in resource_candidates:
|
for candidate in resource_candidates:
|
||||||
@ -608,11 +608,6 @@ class FastUrlDispatcher(UrlDispatcher):
|
|||||||
match_dict := (await candidate.resolve(request))[0]
|
match_dict := (await candidate.resolve(request))[0]
|
||||||
) is not None:
|
) is not None:
|
||||||
return match_dict
|
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
|
# Finally, fallback to the linear search
|
||||||
return await super().resolve(request)
|
return await super().resolve(request)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user