Skip to content

Commit

Permalink
fix(html): replace relative path with absolute path
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuwn committed Jun 19, 2024
1 parent c3226c1 commit 303d68c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[package]
name = "september"
version = "0.2.19"
version = "0.2.20"
authors = ["Fuwn <[email protected]>"]
edition = "2021"
description = "A simple and efficient Gemini-to-HTTP proxy."
Expand Down
20 changes: 12 additions & 8 deletions src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ fn link_from_host_href(url: &Url, href: &str) -> Option<String> {
Some(format!(
"gemini://{}{}{}",
url.domain()?,
{
if href.starts_with('/') {
""
} else {
"/"
}
},
{ if href.starts_with('/') { "" } else { "/" } },
href
))
}
Expand Down Expand Up @@ -73,7 +67,17 @@ pub fn from_gemini(
if href.contains("://") && !href.starts_with("gemini://") {
surface = true;
} else if !href.starts_with("gemini://") && !href.starts_with('/') {
href = format!("./{href}");
href = format!(
"{}/{}",
url.domain().unwrap(),
if url.path().ends_with('/') {
format!("{}{}", url.path(), href)
} else {
format!("{}/{}", url.path(), href)
}
)
.replace("//", "/");
href = format!("gemini://{href}");
} else if href.starts_with('/') || !href.contains("://") {
href = link_from_host_href(url, &href)?;
}
Expand Down

0 comments on commit 303d68c

Please sign in to comment.