Skip to content

Commit

Permalink
root: fix resolve_fragment_in
Browse files Browse the repository at this point in the history
  • Loading branch information
santhosh-tekuri committed Mar 29, 2024
1 parent 15f9898 commit 30bf168
Showing 1 changed file with 5 additions and 23 deletions.
28 changes: 5 additions & 23 deletions src/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ impl Root {
let Some(ptr) = res.anchors.get(anchor) else {
return Err(CompileError::AnchorNotFound {
url: self.url.to_string(),
reference: UrlFrag::format(&self.url, frag.as_str()),
reference: UrlFrag::format(&res.id, frag.as_str()),
});
};
ptr
ptr.clone()
}
Fragment::JsonPointer(ptr) => ptr,
Fragment::JsonPointer(ptr) => res.ptr.concat(ptr),
};
Ok(UrlPtr {
url: self.url.clone(),
ptr: ptr.clone(),
ptr,
})
}

Expand Down Expand Up @@ -67,25 +67,7 @@ impl Root {
}
};

let up = match &loc.frag {
Fragment::JsonPointer(ptr) => UrlPtr {
url: self.url.clone(),
ptr: res.ptr.concat(ptr),
},
Fragment::Anchor(anchor) => {
let Some(anchor_ptr) = res.anchors.get(anchor) else {
return Err(CompileError::AnchorNotFound {
url: self.url.as_str().to_owned(),
reference: loc.to_string(),
});
};
UrlPtr {
url: self.url.clone(),
ptr: anchor_ptr.clone(),
}
}
};
Ok(Some(up))
self.resolve_fragment_in(&loc.frag, res).map(Some)
}

pub(crate) fn resource(&self, ptr: &JsonPointer) -> &Resource {
Expand Down

0 comments on commit 30bf168

Please sign in to comment.