This is an automated email from the ASF dual-hosted git repository. gaul pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/jclouds.git
The following commit(s) were added to refs/heads/master by this push: new ddfb2ea77f Modify S3 endpoint regex pattern to support VPC endpoints. ddfb2ea77f is described below commit ddfb2ea77f36e66ee0d685aaec18ece78185465e Author: John Calcote <john.calc...@hammerspace.com> AuthorDate: Wed Jul 3 18:21:42 2024 +0000 Modify S3 endpoint regex pattern to support VPC endpoints. --- .../main/java/org/jclouds/s3/filters/AwsHostNameUtils.java | 4 ++-- .../java/org/jclouds/s3/filters/AwsHostNameUtilsTest.java | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/apis/s3/src/main/java/org/jclouds/s3/filters/AwsHostNameUtils.java b/apis/s3/src/main/java/org/jclouds/s3/filters/AwsHostNameUtils.java index e133aa3ade..fa12998a5c 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/filters/AwsHostNameUtils.java +++ b/apis/s3/src/main/java/org/jclouds/s3/filters/AwsHostNameUtils.java @@ -26,7 +26,7 @@ import java.util.regex.Pattern; public class AwsHostNameUtils { - private static final Pattern S3_ENDPOINT_PATTERN = Pattern.compile("^(?:.+\\.)?s3[.-]([a-z0-9-]+)$"); + private static final Pattern S3_ENDPOINT_PATTERN = Pattern.compile("^(?:.+\\.)?s3[.\\-]([a-z0-9-]+)(?>\\.[a-z0-9-]+)*$"); private static final Pattern STANDARD_CLOUDSEARCH_ENDPOINT_PATTERN = Pattern.compile("^(?:.+\\.)?([a-z0-9-]+)\\.cloudsearch$"); @@ -107,7 +107,7 @@ public class AwsHostNameUtils { Matcher matcher = S3_ENDPOINT_PATTERN.matcher(fragment); if (matcher.matches()) { - // host was 'bucket.s3-[region].amazonaws.com'. + // host was '[whatever].s3[.|-]-[region].[whatever].amazonaws.com return matcher.group(1); } diff --git a/apis/s3/src/test/java/org/jclouds/s3/filters/AwsHostNameUtilsTest.java b/apis/s3/src/test/java/org/jclouds/s3/filters/AwsHostNameUtilsTest.java index 6e160cd928..6d9c53e961 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/filters/AwsHostNameUtilsTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/filters/AwsHostNameUtilsTest.java @@ -52,10 +52,20 @@ public class AwsHostNameUtilsTest { "s3" ); - Assert.assertEquals( AwsHostNameUtils.parseServiceName(URI.create("https://test-bucket.s3.cn-north-1.amazonaws.com.cn")), "s3" ); } + + @Test + // test s3 virtual private cloud URL + public void testVpcUrl() { + Assert.assertEquals( + AwsHostNameUtils.parseServiceName( + URI.create("https://bucket.vpce-0037af66cf9b0cc5e-zop31d9j.s3.us-east-1.vpce.amazonaws.com") + ), + "s3" + ); + } }