♻️ Simple & Efficient Gemini-to-HTTP Proxy fuwn.net
proxy gemini-protocol protocol gemini http rust
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor(url): simplify approach

Fuwn ccfbaf87 01ec3ddf

+46 -52
+46 -52
src/url.rs
··· 5 5 fallback: bool, 6 6 configuration: &mut crate::response::configuration::Configuration, 7 7 ) -> Result<Url, url::ParseError> { 8 - Ok( 9 - #[allow(clippy::blocks_in_conditions)] 10 - match Url::try_from(&*if path.starts_with("/proxy") { 11 - configuration.set_proxy(true); 8 + Url::try_from(&*if path.starts_with("/proxy") { 9 + configuration.set_proxy(true); 12 10 13 - format!( 14 - "gemini://{}{}", 15 - path.replace("/proxy/", ""), 16 - if fallback { "/" } else { "" } 17 - ) 18 - } else if path.starts_with("/x") { 19 - configuration.set_proxy(true); 11 + format!( 12 + "gemini://{}{}", 13 + path.replace("/proxy/", ""), 14 + if fallback { "/" } else { "" } 15 + ) 16 + } else if path.starts_with("/x") { 17 + configuration.set_proxy(true); 20 18 21 - format!( 22 - "gemini://{}{}", 23 - path.replace("/x/", ""), 24 - if fallback { "/" } else { "" } 25 - ) 26 - } else if path.starts_with("/raw") { 27 - configuration.set_proxy(true); 28 - configuration.set_raw(true); 19 + format!( 20 + "gemini://{}{}", 21 + path.replace("/x/", ""), 22 + if fallback { "/" } else { "" } 23 + ) 24 + } else if path.starts_with("/raw") { 25 + configuration.set_proxy(true); 26 + configuration.set_raw(true); 29 27 30 - format!( 31 - "gemini://{}{}", 32 - path.replace("/raw/", ""), 33 - if fallback { "/" } else { "" } 34 - ) 35 - } else if path.starts_with("/nocss") { 36 - configuration.set_proxy(true); 37 - configuration.set_no_css(true); 28 + format!( 29 + "gemini://{}{}", 30 + path.replace("/raw/", ""), 31 + if fallback { "/" } else { "" } 32 + ) 33 + } else if path.starts_with("/nocss") { 34 + configuration.set_proxy(true); 35 + configuration.set_no_css(true); 38 36 39 - format!( 40 - "gemini://{}{}", 41 - path.replace("/nocss/", ""), 42 - if fallback { "/" } else { "" } 43 - ) 44 - } else { 45 - format!( 46 - "{}{}{}", 47 - { 48 - std::env::var("ROOT").unwrap_or_else(|_| { 49 - warn!( 50 - "could not use ROOT from environment variables, proceeding with \ 51 - default root: gemini://fuwn.me" 52 - ); 37 + format!( 38 + "gemini://{}{}", 39 + path.replace("/nocss/", ""), 40 + if fallback { "/" } else { "" } 41 + ) 42 + } else { 43 + format!( 44 + "{}{}{}", 45 + { 46 + std::env::var("ROOT").unwrap_or_else(|_| { 47 + warn!( 48 + "could not use ROOT from environment variables, proceeding with \ 49 + default root: gemini://fuwn.me" 50 + ); 53 51 54 - "gemini://fuwn.me".to_string() 55 - }) 56 - }, 57 - path, 58 - if fallback { "/" } else { "" } 59 - ) 60 - }) { 61 - Ok(url) => url, 62 - Err(e) => return Err(e), 63 - }, 64 - ) 52 + "gemini://fuwn.me".to_string() 53 + }) 54 + }, 55 + path, 56 + if fallback { "/" } else { "" } 57 + ) 58 + }) 65 59 }