add ending slash, reorganize conditions

This commit is contained in:
yggverse 2025-03-15 13:55:27 +02:00
parent 0364760a35
commit 2870aeb3fb
2 changed files with 10 additions and 14 deletions

View file

@ -32,21 +32,17 @@ impl Link {
// Relative scheme patch
// https://datatracker.ietf.org/doc/html/rfc3986#section-4.2
if let Some(p) = unresolved_address.strip_prefix("//") {
let b = base?;
let postfix = p.trim_start_matches(":");
match base {
Some(b) => {
unresolved_address = format!(
"{}://{}",
b.scheme(),
if postfix.is_empty() {
b.host()?
} else {
postfix.into()
}
)
unresolved_address = format!(
"{}://{}",
b.scheme(),
if postfix.is_empty() {
format!("{}/", b.host()?)
} else {
postfix.into()
}
None => return None,
}
)
}
// Convert address to the valid URI
let uri = match base {

View file

@ -227,7 +227,7 @@ fn gemtext() {
assert_eq!(item.alt, None);
assert_eq!(item.timestamp, None);
assert_eq!(item.uri.to_str(), "gemini://geminiprotocol.net");
assert_eq!(item.uri.to_str(), "gemini://geminiprotocol.net/");
} // #8
// Validate lists