pitchfork_cli/proxy/
mod.rs1pub mod hosts;
14pub mod lan_ip;
15pub mod mdns;
16pub mod server;
17pub mod trust;
18pub mod worktree;
19
20pub fn build_proxy_url(slug: Option<&str>, s: &crate::settings::Settings) -> Option<String> {
27 if !s.proxy.enable {
28 return None;
29 }
30 let slug = slug?;
31
32 let scheme = if s.proxy.https { "https" } else { "http" };
33 let tld = &s.proxy.tld;
34 let standard_port = if s.proxy.https { 443u16 } else { 80u16 };
35
36 let effective_port = u16::try_from(s.proxy.port).ok().filter(|&p| p > 0)?;
37
38 let host = format!("{slug}.{tld}");
39
40 Some(if effective_port == standard_port {
41 format!("{scheme}://{host}")
42 } else {
43 format!("{scheme}://{host}:{effective_port}")
44 })
45}