-- Leo's gemini proxy
-- Connecting to typed-hole.org:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini
commit 26f623460c6e5c18cd7435cf42afdd22d120de60
Author: Julien Blanchard <julien@sideburns.eu>
Date: Sun Aug 25 14:02:20 2019 +0200
Sean's Conman test suite regarding URLs is passing
diff --git a/src/history.rs b/src/history.rs
index 6093ef4..e64edb1 100644
--- a/src/history.rs
+++ b/src/history.rs
@@ -32,3 +32,17 @@ pub fn get_current_host() -> Option<String> {
None => None
}
}
+
+pub fn get_current_url() -> Option<String> {
+ let history = HISTORY.lock().unwrap();
+ match history.last() {
+ Some(current_url) => {
+ let current_path = current_url.join("./");
+ match current_path {
+ Ok(path) => Some(path.to_string()),
+ Err(_) => None
+ }
+ }
+ None => None
+ }
+}
diff --git a/src/main.rs b/src/main.rs
index a7dfeff..13367e6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -250,15 +250,20 @@ fn make_absolute(url: &str) -> Result<url::Url, url::ParseError> {
Some(host) => {
if url.starts_with("gemini://") {
Url::parse(url)
+ } else if url.starts_with("//") {
+ Url::parse(&format!("gemini:{}", url))
} else if url.starts_with('/') {
Url::parse(&format!("gemini://{}{}", host, url))
} else {
- Url::parse(&format!("gemini://{}/{}", host, url))
+ let current_host_path = history::get_current_url().unwrap();
+ Url::parse(&format!("{}{}", current_host_path, url))
}
}
None => {
if url.starts_with("gemini://") {
Url::parse(url)
+ } else if url.starts_with("//") {
+ Url::parse(&format!("gemini:{}", url))
} else {
Url::parse(&format!("gemini://{}", url))
}
---
Served by Pollux Gemini Server.
-- Response ended
-- Page fetched on Sun May 19 10:03:20 2024