Avoid netloc ipaddress re-encoding to construct ingress urls (#116431)

This commit is contained in:
J. Nick Koston 2024-04-30 11:44:25 -05:00 committed by GitHub
parent ff104f54b5
commit 6be2b334d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -67,15 +67,15 @@ class HassIOIngress(HomeAssistantView):
"""Initialize a Hass.io ingress view."""
self._host = host
self._websession = websession
self._url = URL(f"http://{host}")
@lru_cache
def _create_url(self, token: str, path: str) -> URL:
"""Create URL to service."""
base_path = f"/ingress/{token}/"
url = f"http://{self._host}{base_path}{quote(path)}"
try:
target_url = URL(url)
target_url = self._url.join(URL(f"{base_path}{quote(path)}"))
except ValueError as err:
raise HTTPBadRequest from err