Skip to content

Commit 126960d

Browse files
author
bruvio
committed
refactor of extract_id function
1 parent da633cf commit 126960d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

fairdatapipeline/fdp_utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,11 @@ def extract_id(url: str) -> str:
104104
Returns:
105105
| str: id derrived from the url
106106
"""
107-
try:
108-
return list(filter(None, urlsplit(url).path.split("/")))[-1]
109-
except IndexError:
110-
raise IndexError(f"Unable to index input url: {url}")
107+
108+
split_url_path = urlsplit(url).path.split("/")
109+
if not split_url_path:
110+
raise IndexError(f"Unable to extract ID from registry URL: {url}")
111+
return [s for s in split_url_path if s != ""][-1]
111112

112113

113114
def post_entry(

0 commit comments

Comments
 (0)