This repository was archived by the owner on Aug 6, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
main/java/org/jclouds/s3/filters
test/java/org/jclouds/s3/filters Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626
2727public class AwsHostNameUtils {
2828
29- private static final Pattern S3_ENDPOINT_PATTERN = Pattern .compile ("^(?:.+\\ .)?s3[.-]([a-z0-9-]+)$" );
29+ private static final Pattern S3_ENDPOINT_PATTERN = Pattern .compile ("^(?:.+\\ .)?s3[.\\ -]([a-z0-9-]+)(?> \\ .[a-z0-9-]+)* $" );
3030
3131 private static final Pattern STANDARD_CLOUDSEARCH_ENDPOINT_PATTERN = Pattern .compile ("^(?:.+\\ .)?([a-z0-9-]+)\\ .cloudsearch$" );
3232
@@ -107,7 +107,7 @@ private static String parseStandardRegionName(final String fragment) {
107107
108108 Matcher matcher = S3_ENDPOINT_PATTERN .matcher (fragment );
109109 if (matcher .matches ()) {
110- // host was 'bucket .s3- [region].amazonaws.com'.
110+ // host was '[whatever] .s3[.|-]- [region].[whatever]. amazonaws.com
111111 return matcher .group (1 );
112112 }
113113
Original file line number Diff line number Diff line change @@ -52,10 +52,20 @@ public void testParseService() {
5252 "s3"
5353 );
5454
55-
5655 Assert .assertEquals (
5756 AwsHostNameUtils .parseServiceName (URI .create ("https://test-bucket.s3.cn-north-1.amazonaws.com.cn" )),
5857 "s3"
5958 );
6059 }
60+
61+ @ Test
62+ // test s3 virtual private cloud URL
63+ public void testVpcUrl () {
64+ Assert .assertEquals (
65+ AwsHostNameUtils .parseServiceName (
66+ URI .create ("https://bucket.vpce-0037af66cf9b0cc5e-zop31d9j.s3.us-east-1.vpce.amazonaws.com" )
67+ ),
68+ "s3"
69+ );
70+ }
6171}
You can’t perform that action at this time.
0 commit comments