diff --git a/object_store/src/gcp/builder.rs b/object_store/src/gcp/builder.rs index 2039d2378392..5f718d63d94a 100644 --- a/object_store/src/gcp/builder.rs +++ b/object_store/src/gcp/builder.rs @@ -337,13 +337,8 @@ impl GoogleCloudStorageBuilder { let parsed = Url::parse(url).context(UnableToParseUrlSnafu { url })?; let host = parsed.host_str().context(UrlNotRecognisedSnafu { url })?; - let validate = |s: &str| match s.contains('.') { - true => Err(UrlNotRecognisedSnafu { url }.build()), - false => Ok(s.to_string()), - }; - match parsed.scheme() { - "gs" => self.bucket_name = Some(validate(host)?), + "gs" => self.bucket_name = Some(host.to_string()), scheme => return Err(UnknownUrlSchemeSnafu { scheme }.build().into()), } Ok(()) @@ -630,13 +625,12 @@ mod tests { fn gcs_test_urls() { let mut builder = GoogleCloudStorageBuilder::new(); builder.parse_url("gs://bucket/path").unwrap(); - assert_eq!(builder.bucket_name, Some("bucket".to_string())); + assert_eq!(builder.bucket_name.as_deref(), Some("bucket")); - let err_cases = ["mailto://bucket/path", "gs://bucket.mydomain/path"]; - let mut builder = GoogleCloudStorageBuilder::new(); - for case in err_cases { - builder.parse_url(case).unwrap_err(); - } + builder.parse_url("gs://bucket.mydomain/path").unwrap(); + assert_eq!(builder.bucket_name.as_deref(), Some("bucket.mydomain")); + + builder.parse_url("mailto://bucket/path").unwrap_err(); } #[test] diff --git a/object_store/src/parse.rs b/object_store/src/parse.rs index 170726f45290..51993e245530 100644 --- a/object_store/src/parse.rs +++ b/object_store/src/parse.rs @@ -234,6 +234,10 @@ mod tests { "gs://bucket/path", (ObjectStoreScheme::GoogleCloudStorage, "path"), ), + ( + "gs://test.example.com/path", + (ObjectStoreScheme::GoogleCloudStorage, "path"), + ), ("http://mydomain/path", (ObjectStoreScheme::Http, "path")), ("https://mydomain/path", (ObjectStoreScheme::Http, "path")), ];