forked from alemi/upub
fix(apb): setting href always succeeds
This commit is contained in:
parent
65aee2a27e
commit
eddde7c8b9
1 changed files with 1 additions and 3 deletions
|
@ -65,17 +65,15 @@ impl Link for serde_json::Value {
|
||||||
|
|
||||||
#[cfg(feature = "unstructured")]
|
#[cfg(feature = "unstructured")]
|
||||||
impl LinkMut for serde_json::Value {
|
impl LinkMut for serde_json::Value {
|
||||||
// TODO this can fail, but it should never do!
|
|
||||||
fn set_href(mut self, href: &str) -> Self {
|
fn set_href(mut self, href: &str) -> Self {
|
||||||
match &mut self {
|
match &mut self {
|
||||||
serde_json::Value::String(x) => *x = href.to_string(),
|
|
||||||
serde_json::Value::Object(map) => {
|
serde_json::Value::Object(map) => {
|
||||||
map.insert(
|
map.insert(
|
||||||
"href".to_string(),
|
"href".to_string(),
|
||||||
serde_json::Value::String(href.to_string())
|
serde_json::Value::String(href.to_string())
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
_ => tracing::error!("failed setting href on invalid json Link object"),
|
x => *x = serde_json::Value::String(href.to_string()),
|
||||||
}
|
}
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue