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,21 +32,17 @@ impl Link {
|
||||||
// Relative scheme patch
|
// Relative scheme patch
|
||||||
// https://datatracker.ietf.org/doc/html/rfc3986#section-4.2
|
// https://datatracker.ietf.org/doc/html/rfc3986#section-4.2
|
||||||
if let Some(p) = unresolved_address.strip_prefix("//") {
|
if let Some(p) = unresolved_address.strip_prefix("//") {
|
||||||
|
let b = base?;
|
||||||
let postfix = p.trim_start_matches(":");
|
let postfix = p.trim_start_matches(":");
|
||||||
match base {
|
unresolved_address = format!(
|
||||||
Some(b) => {
|
"{}://{}",
|
||||||
unresolved_address = format!(
|
b.scheme(),
|
||||||
"{}://{}",
|
if postfix.is_empty() {
|
||||||
b.scheme(),
|
format!("{}/", b.host()?)
|
||||||
if postfix.is_empty() {
|
} else {
|
||||||
b.host()?
|
postfix.into()
|
||||||
} else {
|
|
||||||
postfix.into()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
None => return None,
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Convert address to the valid URI
|
// Convert address to the valid URI
|
||||||
let uri = match base {
|
let uri = match base {
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,7 @@ fn gemtext() {
|
||||||
|
|
||||||
assert_eq!(item.alt, None);
|
assert_eq!(item.alt, None);
|
||||||
assert_eq!(item.timestamp, 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
|
} // #8
|
||||||
|
|
||||||
// Validate lists
|
// Validate lists
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue