Skip to content

Commit

Permalink
Modify S3 endpoint regex pattern to support VPC endpoints.
Browse files Browse the repository at this point in the history
  • Loading branch information
John Calcote committed Jul 3, 2024
1 parent f4e986f commit 01f05e2
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

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$");

Expand Down Expand Up @@ -107,7 +107,7 @@ private static String parseStandardRegionName(final String fragment) {

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);
}

Expand Down

0 comments on commit 01f05e2

Please sign in to comment.