mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Avoid stripping url prefixes multiple times or multiple prefixes (#5659)
This commit is contained in:
parent
cb8d862a55
commit
ce7f680fd5
@ -135,10 +135,10 @@ impl Show for Packed<LinkElem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn body_from_url(url: &Url) -> Content {
|
fn body_from_url(url: &Url) -> Content {
|
||||||
let mut text = url.as_str();
|
let text = ["mailto:", "tel:"]
|
||||||
for prefix in ["mailto:", "tel:"] {
|
.into_iter()
|
||||||
text = text.trim_start_matches(prefix);
|
.find_map(|prefix| url.strip_prefix(prefix))
|
||||||
}
|
.unwrap_or(url);
|
||||||
let shorter = text.len() < url.len();
|
let shorter = text.len() < url.len();
|
||||||
TextElem::packed(if shorter { text.into() } else { (**url).clone() })
|
TextElem::packed(if shorter { text.into() } else { (**url).clone() })
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user