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:
@@ -168,7 +168,7 @@ export async function loadActivity(
|
||||
if (cached) return cached;
|
||||
|
||||
try {
|
||||
const url = detailUrl.startsWith('http')
|
||||
const url = detailUrl.startsWith('http') || detailUrl.startsWith('/')
|
||||
? detailUrl
|
||||
: `${baseUrl}data/${detailUrl}`;
|
||||
return await fetchJSON<ActivityDetail>(url);
|
||||
@@ -199,7 +199,7 @@ export async function loadTimeseries(
|
||||
|
||||
if (timeseriesUrl.startsWith('http')) {
|
||||
url = timeseriesUrl;
|
||||
} else if (detailUrl.startsWith('http')) {
|
||||
} else if (detailUrl.startsWith('http') || detailUrl.startsWith('/')) {
|
||||
// absolute detailUrl (browser shard resolution) → same directory
|
||||
const dir = detailUrl.substring(0, detailUrl.lastIndexOf('/') + 1);
|
||||
url = `${dir}${filename}`;
|
||||
|
||||
Reference in New Issue
Block a user