diff --git a/src/api/s3/website.rs b/src/api/s3/website.rs index ad592260..6ec786a0 100644 --- a/src/api/s3/website.rs +++ b/src/api/s3/website.rs @@ -330,12 +330,10 @@ impl Condition { impl Redirect { pub fn validate(&self) -> Result<(), Error> { - if self.replace_prefix.is_some() { - if self.replace_full.is_some() { - return Err(Error::bad_request( - "Bad XML: both ReplaceKeyPrefixWith and ReplaceKeyWith are set", - )); - } + if self.replace_prefix.is_some() && self.replace_full.is_some() { + return Err(Error::bad_request( + "Bad XML: both ReplaceKeyPrefixWith and ReplaceKeyWith are set", + )); } if let Some(ref protocol) = self.protocol { if protocol.0 != "http" && protocol.0 != "https" { diff --git a/src/model/bucket_table.rs b/src/model/bucket_table.rs index 625c177d..644189b2 100644 --- a/src/model/bucket_table.rs +++ b/src/model/bucket_table.rs @@ -90,21 +90,21 @@ mod v08 { let mut res = String::new(); if let Some(hostname) = &self.hostname { if let Some(protocol) = &self.protocol { - res.push_str(&protocol); + res.push_str(protocol); res.push_str("://"); } else { res.push_str("//"); } - res.push_str(&hostname); + res.push_str(hostname); } res.push('/'); if let Some(replace_key_prefix) = &self.replace_key_prefix { - res.push_str(&replace_key_prefix); + res.push_str(replace_key_prefix); if let Some(suffix) = suffix { res.push_str(suffix) } } else if let Some(replace_key) = &self.replace_key { - res.push_str(&replace_key) + res.push_str(replace_key) } res } diff --git a/src/web/web_server.rs b/src/web/web_server.rs index dfdbf8a2..c497270a 100644 --- a/src/web/web_server.rs +++ b/src/web/web_server.rs @@ -476,8 +476,8 @@ impl RoutingResult { /// which is also AWS S3 behavior. /// /// Check: https://docs.aws.amazon.com/AmazonS3/latest/userguide/IndexDocumentSupport.html -fn path_to_keys<'a>( - path: &'a str, +fn path_to_keys( + path: &str, index: &str, routing_rules: &[RoutingRule], ) -> Result { @@ -488,7 +488,7 @@ fn path_to_keys<'a>( None => return Err(Error::BadRequest("Path must start with a / (slash)".into())), }; - let is_bucket_root = base_key.len() == 0; + let is_bucket_root = base_key.is_empty(); let is_trailing_slash = path_utf8.ends_with("/"); let key = if is_bucket_root || is_trailing_slash {