Commit fe36af8d authored by Nugine's avatar Nugine
Browse files

feat(s3s): check_bucket_name as default optional feature

parent 79514f98
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[features]
default = ["check-bucket-name"]
check-bucket-name = []
openssl = ["dep:openssl"]

[target.'cfg(not(windows))'.dependencies]
+6 −1
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
//! + [Bucket naming rules](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html)

use std::net::IpAddr;
use std::ops::Not as _;

/// A path in the S3 storage
#[derive(Debug, PartialEq, Eq)]
@@ -108,9 +109,13 @@ impl S3Path {
}

/// See [bucket naming rules](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html)
#[allow(clippy::manual_is_variant_and)] // FIXME: https://github.com/rust-lang/rust-clippy/issues/15202
#[allow(clippy::manual_is_variant_and)]
#[must_use]
pub fn check_bucket_name(name: &str) -> bool {
    if cfg!(not(feature = "check-bucket-name")) {
        return name.is_empty().not();
    }

    if !(3_usize..64).contains(&name.len()) {
        return false;
    }