(flag: &str, spec: &str, host: &str)
| 408 | } |
| 409 | |
| 410 | fn parse_host(flag: &str, spec: &str, host: &str) -> Result<String> { |
| 411 | let host = host.trim(); |
| 412 | if host.is_empty() { |
| 413 | return Err(miette!("{flag} has an empty host segment in '{spec}'")); |
| 414 | } |
| 415 | if host.contains(char::is_whitespace) { |
| 416 | return Err(miette!( |
| 417 | "{flag} host must not contain whitespace in '{spec}'" |
| 418 | )); |
| 419 | } |
| 420 | if host.contains('/') { |
| 421 | return Err(miette!("{flag} host must not contain '/' in '{spec}'")); |
| 422 | } |
| 423 | Ok(host.to_string()) |
| 424 | } |
| 425 | |
| 426 | fn parse_port(flag: &str, spec: &str, port: &str) -> Result<u32> { |
| 427 | let port = port.trim(); |
no test coverage detected