diff --git a/src/IO/S3Common.cpp b/src/IO/S3Common.cpp index a6b518afcdc..e809474bc98 100644 --- a/src/IO/S3Common.cpp +++ b/src/IO/S3Common.cpp @@ -111,7 +111,7 @@ namespace S3 if (!client_configuration.endpointOverride.empty()) { - static const RE2 region_pattern(R"(s3[.\-]([a-z0-9\-]+)\.amazonaws\.)"); + static const RE2 region_pattern(R"(^s3[.\-]([a-z0-9\-]+)\.amazonaws\.)"); Poco::URI uri(client_configuration.endpointOverride); if (uri.getScheme() == "http") client_configuration.scheme = Aws::Http::Scheme::HTTP; @@ -138,6 +138,7 @@ namespace S3 /// E.g. (https://bucket-name.s3.Region.amazonaws.com/key) /// https://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html#virtual-hosted-style-access static const RE2 virtual_hosted_style_pattern(R"((.+)\.(s3[.\-][a-z0-9\-.:]+))"); + /// Case when bucket name and key represented in path of S3 URL. /// E.g. (https://s3.Region.amazonaws.com/bucket-name/key) /// https://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html#path-style-access diff --git a/src/IO/tests/gtest_s3_uri.cpp b/src/IO/tests/gtest_s3_uri.cpp index accb81a6306..3609d8c25cd 100644 --- a/src/IO/tests/gtest_s3_uri.cpp +++ b/src/IO/tests/gtest_s3_uri.cpp @@ -17,7 +17,7 @@ TEST(S3UriTest, validPatterns) { { S3::URI uri(Poco::URI("https://jokserfn.s3.yandexcloud.net/data")); - ASSERT_EQ("https://jokserfn.s3.yandexcloud.net", uri.endpoint); + ASSERT_EQ("https://s3.yandexcloud.net", uri.endpoint); ASSERT_EQ("jokserfn", uri.bucket); ASSERT_EQ("data", uri.key); }