pub fn safe_href(url: &str, base: &str) -> Option<String>Expand description
Screen a link / image target. Absolute http(s) and #fragment targets
pass; protocol-relative and any other scheme are refused; a relative path
with an empty or .. segment (or a leading /) is refused, otherwise it
is joined onto base.
ยงExamples
use solid_pod_rs_forge::markdown::safe_href;
assert_eq!(safe_href("https://x.test/a", "/b").as_deref(), Some("https://x.test/a"));
assert_eq!(safe_href("docs/n.txt", "/blob").as_deref(), Some("/blob/docs/n.txt"));
assert_eq!(safe_href("javascript:alert(1)", "/b"), None);
assert_eq!(safe_href("../x", "/b"), None);
assert_eq!(safe_href("//evil.test/x", "/b"), None);