in elasticsearch/src/http/transport.rs [596:617]
fn parse_to_url(address: &str, scheme: &str) -> Result<Url, Error> {
if address.is_empty() {
return Err(crate::error::lib("Bound Address is empty"));
}
let mut host_port = None;
if let Some((host, tail)) = address.split_once('/') {
if let Some((_, port)) = tail.rsplit_once(':') {
host_port = Some((host, port));
}
} else {
host_port = address.rsplit_once(':');
}
let (host, port) = host_port.ok_or_else(|| {
crate::error::lib(format!("error parsing address into url: {}", address))
})?;
Ok(Url::parse(
format!("{}://{}:{}", scheme, host, port).as_str(),
)?)
}