-- Leo's gemini proxy
-- Connecting to typed-hole.org:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini
commit 188cd6c5086454b0454353c5341dd332e0e36b36
Author: Julien Blanchard <julien@sideburns.eu>
Date: Tue Apr 21 20:41:00 2020 +0200
[gopher] temporary fix for urls that were not working
diff --git a/src/gopher/client.rs b/src/gopher/client.rs
index 138bc5f..07f4a4c 100644
--- a/src/gopher/client.rs
+++ b/src/gopher/client.rs
@@ -29,8 +29,10 @@ pub fn get_data<T: Protocol>(url: T) -> Result<(Option<Vec<u8>>, Vec<u8>), Strin
None => format!("{}\n", path),
};
- let url = if url.starts_with("/0/") || url.starts_with("/1/") || url.starts_with("/g/") {
+ let url = if url.starts_with("/0") || url.starts_with("/1") || url.starts_with("/g") {
url.split_off(2)
+ } else if url == "/\n" {
+ String::from("\r\n")
} else {
url
};
diff --git a/src/gopher/link.rs b/src/gopher/link.rs
index 0f4c5ac..7e18cfb 100644
--- a/src/gopher/link.rs
+++ b/src/gopher/link.rs
@@ -28,24 +28,28 @@ impl FromStr for Link {
let port = els.next();
if let Some(host) = host {
- if let Some(p) = path {
+ if let Some(path) = path {
let mut text = String::from(label);
let selector = text.remove(0);
- let path = if p.starts_with('/') {
- p.to_string()
- } else {
- format!("/{}", p)
- };
-
if let Some(port) = port {
- match Url::parse(&format!("gopher://{}:{}/{}{}", host, port, selector, path)) {
- Ok(url) => Ok(Link::Gopher(url, text)),
- Err(e) => {
- println!("ERR {:?}", e);
- Err(ParseError)
- }
- }
+ if path != "" {
+ match Url::parse(&format!("gopher://{}:{}/{}{}", host, port, selector, path)) {
+ Ok(url) => Ok(Link::Gopher(url, text)),
+ Err(e) => {
+ println!("ERR {:?}", e);
+ Err(ParseError)
+ }
+ }
+ } else {
+ match Url::parse(&format!("gopher://{}:{}", host, port)) {
+ Ok(url) => Ok(Link::Gopher(url, text)),
+ Err(e) => {
+ println!("ERR {:?}", e);
+ Err(ParseError)
+ }
+ }
+ }
} else {
Err(ParseError)
}
---
Served by Pollux Gemini Server.
-- Response ended
-- Page fetched on Sun May 19 04:55:45 2024