From c2d24407b8f420e2bd3e0337dd92036675f9ec67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20G=C3=B6rresen=20Mello?= Date: Fri, 13 Feb 2026 09:12:27 -0300 Subject: [PATCH] fixing fetchdir to work with relative URLs --- alephclient/fetchdir.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/alephclient/fetchdir.py b/alephclient/fetchdir.py index 6d4bbff..215a907 100644 --- a/alephclient/fetchdir.py +++ b/alephclient/fetchdir.py @@ -3,6 +3,7 @@ from pathlib import Path from pprint import pprint # noqa from typing import Optional, Dict +from urllib.parse import urlparse, urljoin from alephclient.api import AlephAPI @@ -36,6 +37,9 @@ def fetch_object(api: AlephAPI, path: Path, entity: Dict, overwrite: bool = Fals object_path = path.joinpath(file_name) url = entity.get("links", {}).get("file") if url is not None: + # Aleph Pro may return relative URLs (e.g. /api/2/archive?token=...) + if not urlparse(url).scheme: + url = urljoin(api.base_url, url) # Skip existing files after checking file size: if not overwrite and object_path.exists(): for file_size in entity.get("properties", {}).get("fileSize", []):