mirror of
https://github.com/apache/jclouds.git
synced 2026-08-07 12:46:56 +00:00
Modify S3 endpoint regex pattern to support VPC endpoints.
This commit is contained in:
committed by
Andrew Gaul
parent
f4e986f8fb
commit
ddfb2ea77f
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user