(authority: &str)
| 303 | } |
| 304 | |
| 305 | fn 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 | |
| 325 | fn normalize_host(host: &str) -> Option<String> { |
| 326 | let host = host.trim().trim_end_matches('.').to_ascii_lowercase(); |
no test coverage detected