🐛 (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:
parent
0de6c2a88f
commit
6c27964edd
1 changed files with 4 additions and 1 deletions
|
|
@ -126,8 +126,11 @@ class CustomComponent(Component):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def resolve_path(path: str) -> str:
|
def resolve_path(path: str) -> str:
|
||||||
"""Resolves the path to an absolute path."""
|
"""Resolves the path to an absolute path."""
|
||||||
|
if not path:
|
||||||
|
return path
|
||||||
path_object = Path(path)
|
path_object = Path(path)
|
||||||
if path_object.parts[0] == "~":
|
|
||||||
|
if path_object.parts and path_object.parts[0] == "~":
|
||||||
path_object = path_object.expanduser()
|
path_object = path_object.expanduser()
|
||||||
elif path_object.is_relative_to("."):
|
elif path_object.is_relative_to("."):
|
||||||
path_object = path_object.resolve()
|
path_object = path_object.resolve()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue