(scheme: &str, authority: &str)
| 282 | } |
| 283 | |
| 284 | fn parse_origin_authority(scheme: &str, authority: &str) -> Option<Origin> { |
| 285 | let scheme = scheme.to_ascii_lowercase(); |
| 286 | let default_port = match scheme.as_str() { |
| 287 | "http" => 80, |
| 288 | "https" => 443, |
| 289 | _ => return None, |
| 290 | }; |
| 291 | let authority = authority.trim(); |
| 292 | if authority.is_empty() || authority.contains('@') { |
| 293 | return None; |
| 294 | } |
| 295 | |
| 296 | let (host, port) = split_host_port(authority)?; |
| 297 | let host = normalize_host(host)?; |
| 298 | Some(Origin { |
| 299 | scheme, |
| 300 | host, |
| 301 | port: port.unwrap_or(default_port), |
| 302 | }) |
| 303 | } |
| 304 | |
| 305 | fn split_host_port(authority: &str) -> Option<(&str, Option<u16>)> { |
| 306 | if let Some(rest) = authority.strip_prefix('[') { |
no test coverage detected