Skip to content

Commit

Permalink
If id of fetched object doesnt match url, refetch it (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nutomic committed Sep 13, 2024
1 parent 83a1563 commit c4b24bd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/fetch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ pub async fn fetch_object_http<T: Clone, Kind: DeserializeOwned>(

// 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));
}

Expand Down

0 comments on commit c4b24bd

Please sign in to comment.