pub(crate) fn normalize_host(target: &str) -> String {
let mut s = target;
if let Some(rest) = s.strip_prefix("http://") {
s = rest;
} else if let Some(rest) = s.strip_prefix("https://") {
s = rest;
}
let is_url_like = target.starts_with("http://") || target.starts_with("https://");
if is_url_like {
if let Some(idx) = s.find(':') {
s = &s[..idx];
}
if let Some(idx) = s.find('/') {
s = &s[..idx];
}
} else {
if let Some(idx) = s.find('/') {
s = &s[..idx];
}
if let Some(idx) = s.find(':') {
if s[idx + 1..]
.chars()
.take_while(|c| c.is_ascii_digit())
.count()
> 0
{
s = &s[..idx];
}
}
}
s.to_string()
}