-- Leo's gemini proxy

-- Connecting to typed-hole.org:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

commit d977bae21d9a323d2a0ec098e365b5b960781c8b

Author: Julien Blanchard <julien@sideburns.eu>

Date: Mon Aug 12 12:32:09 2019 +0200


Send absolute URLs to servers


diff --git a/Cargo.lock b/Cargo.lock

index c6d8d84..081513a 100644

--- a/Cargo.lock

+++ b/Cargo.lock

@@ -20,7 +20,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"


[[package]]

name = "asuka"

-version = "0.1.0"

+version = "0.2.0"

dependencies = [

"cursive 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",

"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",

diff --git a/src/content.rs b/src/content.rs

index 59c1c42..5f692a3 100644

--- a/src/content.rs

+++ b/src/content.rs

@@ -5,7 +5,6 @@ use std::net::TcpStream;


pub fn get_data(url: &url::Url) -> Result<String, String> {

let host = url.host_str().unwrap();

- let path = url.path();

let urlf = format!("{}:1965", host);


let mut builder = TlsConnector::builder();

@@ -21,8 +20,8 @@ pub fn get_data(url: &url::Url) -> Result<String, String> {


match mstream {

Ok(mut stream) => {

- let url_with_path = format!("{}\r\n", path);

- stream.write_all(url_with_path.as_bytes()).unwrap();

+ let url = format!("{}\r\n", url);

+ stream.write_all(url.as_bytes()).unwrap();

let mut res = vec![];

stream.read_to_end(&mut res).unwrap();

Ok(String::from_utf8_lossy(&res).to_string())

diff --git a/src/history.rs b/src/history.rs

index 4f81daf..6093ef4 100644

--- a/src/history.rs

+++ b/src/history.rs

@@ -25,7 +25,7 @@ pub fn get_current_host() -> Option<String> {

match history.last() {

Some(current_url) => {

match current_url.host_str() {

- Some(host) => Some(host.to_owned()),

+ Some(host) => Some(String::from(host)),

None => None

}

}

diff --git a/src/link.rs b/src/link.rs

index 5c1e102..35dfb9d 100644

--- a/src/link.rs

+++ b/src/link.rs

@@ -15,7 +15,7 @@ pub enum Link {

Clone, Copy, PartialEq, Eq, Hash)]

pub struct ParseError;


-const LINK_REGEX: &str = r"^=>\s(\S*)\s*(.*)?$";

+const LINK_REGEX: &str = r"^=>\s?(\S*)\s*(.*)?$";


impl FromStr for Link {

type Err = ParseError;

diff --git a/src/main.rs b/src/main.rs

index 105e6de..5c0ca56 100644

--- a/src/main.rs

+++ b/src/main.rs

@@ -154,8 +154,8 @@ fn draw_content(s: &mut Cursive, url: Url, content: String) {

match link {

Link::Http(_url, label) => {

let mut formatted = StyledString::new();

- let gopher_label = format!("[WWW] {}", label);

- formatted.append(StyledString::styled(gopher_label, Effect::Italic));

+ let www_label = format!("[WWW] {}", label);

+ formatted.append(StyledString::styled(www_label, Effect::Italic));


main_view.add_item(formatted, String::from("0"))

},



---

Served by Pollux Gemini Server.

-- Response ended

-- Page fetched on Sun May 19 11:23:52 2024