mirror of
https://github.com/YGGverse/ggemtext.git
synced 2026-03-31 17:15:33 +00:00
add ending slash, reorganize conditions
This commit is contained in:
parent
0364760a35
commit
2870aeb3fb
2 changed files with 10 additions and 14 deletions
|
|
@ -32,22 +32,18 @@ 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()?
|
||||
format!("{}/", b.host()?)
|
||||
} else {
|
||||
postfix.into()
|
||||
}
|
||||
)
|
||||
}
|
||||
None => return None,
|
||||
}
|
||||
}
|
||||
// Convert address to the valid URI
|
||||
let uri = match base {
|
||||
// Base conversion requested
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue