diff options
| author | Fuwn <[email protected]> | 2025-01-14 08:03:51 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-01-14 08:03:51 +0000 |
| commit | de04ac86db834a96fd72f2cb47da984b190d9ce7 (patch) | |
| tree | f840656641602335447f421d78bc14c0cade966f /src | |
| parent | chore(crate): bump version (diff) | |
| download | september-de04ac86db834a96fd72f2cb47da984b190d9ce7.tar.xz september-de04ac86db834a96fd72f2cb47da984b190d9ce7.zip | |
fix(html): relative url handling
Diffstat (limited to 'src')
| -rw-r--r-- | src/html.rs | 6 | ||||
| -rw-r--r-- | src/response/configuration.rs | 28 |
2 files changed, 26 insertions, 8 deletions
diff --git a/src/html.rs b/src/html.rs index 64ec6ae..933ce8e 100644 --- a/src/html.rs +++ b/src/html.rs @@ -103,6 +103,12 @@ pub fn from_gemini( let mut href = to.to_string(); let mut surface = false; + if href.starts_with("./") || href.starts_with("../") { + if let Ok(url) = url.join(&href) { + href = url.to_string(); + } + } + if href.contains("://") && !href.starts_with("gemini://") { surface = true; } else if !href.contains("://") && href.contains(':') { diff --git a/src/response/configuration.rs b/src/response/configuration.rs index 4278516..42b42f1 100644 --- a/src/response/configuration.rs +++ b/src/response/configuration.rs @@ -1,6 +1,6 @@ pub struct Configuration { - is_proxy: bool, - is_raw: bool, + is_proxy: bool, + is_raw: bool, is_no_css: bool, } @@ -9,15 +9,27 @@ impl Configuration { Self { is_proxy: false, is_raw: false, is_no_css: false } } - pub const fn is_proxy(&self) -> bool { self.is_proxy } + pub const fn is_proxy(&self) -> bool { + self.is_proxy + } - pub const fn is_raw(&self) -> bool { self.is_raw } + pub const fn is_raw(&self) -> bool { + self.is_raw + } - pub const fn is_no_css(&self) -> bool { self.is_no_css } + pub const fn is_no_css(&self) -> bool { + self.is_no_css + } - pub fn set_proxy(&mut self, is_proxy: bool) { self.is_proxy = is_proxy; } + pub fn set_proxy(&mut self, is_proxy: bool) { + self.is_proxy = is_proxy; + } - pub fn set_raw(&mut self, is_raw: bool) { self.is_raw = is_raw; } + pub fn set_raw(&mut self, is_raw: bool) { + self.is_raw = is_raw; + } - pub fn set_no_css(&mut self, is_no_css: bool) { self.is_no_css = is_no_css; } + pub fn set_no_css(&mut self, is_no_css: bool) { + self.is_no_css = is_no_css; + } } |