From a35c8cbea506e68229e7da078fc76d4b7ba93775 Mon Sep 17 00:00:00 2001 From: Nutomic Date: Fri, 13 Sep 2024 16:09:04 +0200 Subject: [PATCH] If id of fetched object doesnt match url, refetch it (#126) --- src/fetch/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/fetch/mod.rs b/src/fetch/mod.rs index f078cf6..e36e8b2 100644 --- a/src/fetch/mod.rs +++ b/src/fetch/mod.rs @@ -73,6 +73,14 @@ pub async fn fetch_object_http( // Ensure id field matches final url after redirect if res.object_id.as_ref() != Some(&res.url) { + if let Some(res_object_id) = res.object_id { + // If id is different but still on the same domain, attempt to request object + // again from url in id field. + if res_object_id.domain() == res.url.domain() { + return Box::pin(fetch_object_http(&res_object_id, data)).await; + } + } + // Failed to fetch the object from its specified id return Err(Error::FetchWrongId(res.url)); }