Use if-let chains

This commit is contained in:
Matt Brubeck 2025-08-21 09:28:45 -07:00
parent cdc72e4f2d
commit 13ad2f363e

View file

@ -290,8 +290,9 @@ fn args() -> Result<Args> {
let hostname = Host::parse(&s)?;
// check if we have a certificate for that domain
if let Host::Domain(ref domain) = hostname {
if !matches!(certs, Some(ref certs) if certs.has_domain(domain)) {
if let Host::Domain(ref domain) = hostname
&& !matches!(certs, Some(ref certs) if certs.has_domain(domain))
{
log::info!("No certificate or key found for {s:?}, generating them.");
let mut cert_params = CertificateParams::new(vec![domain.clone()])?;
@ -339,7 +340,6 @@ fn args() -> Result<Args> {
reload_certs = true;
}
}
hostnames.push(hostname);
}
@ -594,15 +594,15 @@ where
}
// correct port
if let Some(expected_port) = self.local_port_check {
if let Some(port) = url.port() {
if let Some(expected_port) = self.local_port_check
&& let Some(port) = url.port()
{
// Validate that the port in the URL is the same as for the stream this request
// came in on.
if port != expected_port {
return Err((PROXY_REQUEST_REFUSED, "Proxy request refused"));
}
}
}
Ok(url)
}
@ -659,8 +659,9 @@ where
}
}
if let Ok(metadata) = tokio::fs::metadata(&path).await {
if metadata.is_dir() {
if let Ok(metadata) = tokio::fs::metadata(&path).await
&& metadata.is_dir()
{
if url.path().ends_with('/') || url.path().is_empty() {
// if the path ends with a slash or the path is empty, the links will work the same
// without a redirect
@ -678,7 +679,6 @@ where
return self.send_header(REDIRECT_PERMANENT, url.as_str()).await;
}
}
}
let data = self.metadata.lock().await.get(&path);