🐛 (custom_component.py): fix resolving path logic to handle empty path input and check if path parts exist before accessing the first part

This commit is contained in:
ogabrielluiz 2024-06-10 14:12:50 -03:00
commit 6c27964edd

View file

@ -126,8 +126,11 @@ class CustomComponent(Component):
@staticmethod
def resolve_path(path: str) -> str:
"""Resolves the path to an absolute path."""
if not path:
return path
path_object = Path(path)
if path_object.parts[0] == "~":
if path_object.parts and path_object.parts[0] == "~":
path_object = path_object.expanduser()
elif path_object.is_relative_to("."):
path_object = path_object.resolve()