fix: handle absolute detail_url paths in loadActivity and loadTimeseries

resolveShards rewrites detail_url to absolute paths (e.g. /data/brut/_merged/activities/{id}.json)
when fetching from a user shard. loadActivity and loadTimeseries only checked for http:// prefixes
and treated /data/... paths as relative, producing double /data//data/... in the fetch URL → 404.

Fix: treat URLs starting with / as already absolute, same as http:// URLs.
This commit is contained in:
Davide Scaini
2026-04-15 14:44:34 +02:00
parent 290eef6c72
commit f376b24106
+2 -2
View File
@@ -168,7 +168,7 @@ export async function loadActivity(
if (cached) return cached; if (cached) return cached;
try { try {
const url = detailUrl.startsWith('http') const url = detailUrl.startsWith('http') || detailUrl.startsWith('/')
? detailUrl ? detailUrl
: `${baseUrl}data/${detailUrl}`; : `${baseUrl}data/${detailUrl}`;
return await fetchJSON<ActivityDetail>(url); return await fetchJSON<ActivityDetail>(url);
@@ -199,7 +199,7 @@ export async function loadTimeseries(
if (timeseriesUrl.startsWith('http')) { if (timeseriesUrl.startsWith('http')) {
url = timeseriesUrl; url = timeseriesUrl;
} else if (detailUrl.startsWith('http')) { } else if (detailUrl.startsWith('http') || detailUrl.startsWith('/')) {
// absolute detailUrl (browser shard resolution) → same directory // absolute detailUrl (browser shard resolution) → same directory
const dir = detailUrl.substring(0, detailUrl.lastIndexOf('/') + 1); const dir = detailUrl.substring(0, detailUrl.lastIndexOf('/') + 1);
url = `${dir}${filename}`; url = `${dir}${filename}`;