Skip to content

Commit c2d2440

Browse files
committed
fixing fetchdir to work with relative URLs
1 parent b29539f commit c2d2440

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

alephclient/fetchdir.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from pathlib import Path
44
from pprint import pprint # noqa
55
from typing import Optional, Dict
6+
from urllib.parse import urlparse, urljoin
67

78
from alephclient.api import AlephAPI
89

@@ -36,6 +37,9 @@ def fetch_object(api: AlephAPI, path: Path, entity: Dict, overwrite: bool = Fals
3637
object_path = path.joinpath(file_name)
3738
url = entity.get("links", {}).get("file")
3839
if url is not None:
40+
# Aleph Pro may return relative URLs (e.g. /api/2/archive?token=...)
41+
if not urlparse(url).scheme:
42+
url = urljoin(api.base_url, url)
3943
# Skip existing files after checking file size:
4044
if not overwrite and object_path.exists():
4145
for file_size in entity.get("properties", {}).get("fileSize", []):

0 commit comments

Comments
 (0)