INNER CODE UNIT · Rust

panel_host_from_base_url

ovexro/dockpanel · panel/backend/src/routes/mod.rs:150

fn panel_host_from_base_url(base: &str) -> Option<String> {
    let b = base.trim().to_lowercase();
    let hostport = b
        .strip_prefix("https://")
        .or_else(|| b.strip_prefix("http://"))
        .unwrap_or(&b);
    let host = hostport.split('/').next().unwrap_or("");
    // Strip a :port, but never mangle a bare IPv6 literal.
    let host = if host.starts_with('[') {
        host.split(']').next().unwrap_or("").trim_start_matches('[')
    } else {
        host.split(':').next().unwrap_or("")
    };
    (!host.is_empty()).then(|| host.to_string())
}

/// [`is_reserved_domain`] plus the host THIS request arrived on.
///

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…