MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / split_host_port

Function split_host_port

crates/openshell-server/src/http.rs:305–323  ·  view source on GitHub ↗
(authority: &str)

Source from the content-addressed store, hash-verified

303}
304
305fn split_host_port(authority: &str) -> Option<(&str, Option<u16>)> {
306 if let Some(rest) = authority.strip_prefix('[') {
307 let (host, rest) = rest.split_once(']')?;
308 let port = if rest.is_empty() {
309 None
310 } else {
311 Some(rest.strip_prefix(':')?.parse().ok()?)
312 };
313 return Some((host, port));
314 }
315
316 match authority.rsplit_once(':') {
317 Some((host, port)) if !port.is_empty() && port.chars().all(|ch| ch.is_ascii_digit()) => {
318 Some((host, Some(port.parse().ok()?)))
319 }
320 Some(_) if authority.matches(':').count() == 1 => None,
321 _ => Some((authority, None)),
322 }
323}
324
325fn normalize_host(host: &str) -> Option<String> {
326 let host = host.trim().trim_end_matches('.').to_ascii_lowercase();

Callers 1

parse_origin_authorityFunction · 0.85

Calls 2

is_emptyMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected