diff --git a/src/main/java/com/github/vfss3/parser/S3FileNameParser.java b/src/main/java/com/github/vfss3/parser/S3FileNameParser.java index 0840d19..3f0ea42 100644 --- a/src/main/java/com/github/vfss3/parser/S3FileNameParser.java +++ b/src/main/java/com/github/vfss3/parser/S3FileNameParser.java @@ -119,7 +119,7 @@ public FileName parseUri( if ((bucket != null) && (bucket.trim().length() > 0)) { // Has bucket inside URL if ((region != null) && (region.trim().length() > 0)) { - host = "s3-" + region + ".amazonaws.com"; + host = "s3." + region + ".amazonaws.com"; } else { host = "s3.amazonaws.com"; } diff --git a/src/test/java/com/github/vfss3/S3FileNameParserTest.java b/src/test/java/com/github/vfss3/S3FileNameParserTest.java index 38adb39..952667c 100644 --- a/src/test/java/com/github/vfss3/S3FileNameParserTest.java +++ b/src/test/java/com/github/vfss3/S3FileNameParserTest.java @@ -22,18 +22,18 @@ public void checkHostedStyleUrl() throws FileSystemException { hasPathPrefix("bucket"). hasType(FOLDER); - assertThat(parse("s3://bucket.s3-eu-west-1.amazonaws.com")). - hasEndpoint("s3-eu-west-1.amazonaws.com"). + assertThat(parse("s3://bucket.s3.eu-west-1.amazonaws.com")). + hasEndpoint("s3.eu-west-1.amazonaws.com"). hasPathPrefix("bucket"). hasType(FOLDER); - assertThat(parse("s3://bucket.s3-eu-west-1.amazonaws.com/some_file")). - hasEndpoint("s3-eu-west-1.amazonaws.com"). + assertThat(parse("s3://bucket.s3.eu-west-1.amazonaws.com/some_file")). + hasEndpoint("s3.eu-west-1.amazonaws.com"). hasPathPrefix("bucket"). hasType(IMAGINARY); - assertThat(parse("s3://bucket.s3-eu-west-1.amazonaws.com/some file")). - hasEndpoint("s3-eu-west-1.amazonaws.com"). + assertThat(parse("s3://bucket.s3.eu-west-1.amazonaws.com/some file")). + hasEndpoint("s3.eu-west-1.amazonaws.com"). hasPathPrefix("bucket"). hasType(IMAGINARY); @@ -78,8 +78,8 @@ public void checkPathStyleUrl() throws FileSystemException { hasEndpoint("s3.amazonaws.com"). hasPathPrefix("bucket"); - assertThat(parse("s3://s3-eu-west-1.amazonaws.com/bucket")). - hasEndpoint("s3-eu-west-1.amazonaws.com"). + assertThat(parse("s3://s3.eu-west-1.amazonaws.com/bucket")). + hasEndpoint("s3.eu-west-1.amazonaws.com"). hasPathPrefix("bucket"). hasType(FOLDER); @@ -88,14 +88,14 @@ public void checkPathStyleUrl() throws FileSystemException { hasPathPrefix("bucket"). hasType(FOLDER); - assertThat(parse("s3://s3-eu-west-1.amazonaws.com/bucket/gggg")). - hasEndpoint("s3-eu-west-1.amazonaws.com"). + assertThat(parse("s3://s3.eu-west-1.amazonaws.com/bucket/gggg")). + hasEndpoint("s3.eu-west-1.amazonaws.com"). hasPathPrefix("bucket"). hasType(IMAGINARY). hasPath("/gggg"); - assertThat(parse("s3://s3-eu-west-1.amazonaws.com/bucket/concurrent/")). - hasEndpoint("s3-eu-west-1.amazonaws.com"). + assertThat(parse("s3://s3.eu-west-1.amazonaws.com/bucket/concurrent/")). + hasEndpoint("s3.eu-west-1.amazonaws.com"). hasPathPrefix("bucket"). hasType(IMAGINARY). hasPath("/concurrent"); @@ -133,13 +133,13 @@ public void checkLocalStackUrl() throws FileSystemException { @Test public void checkRegionParsing() throws FileSystemException { - assertThat(parse("s3://s3-eu-west-1.amazonaws.com/bucket")). + assertThat(parse("s3://s3.eu-west-1.amazonaws.com/bucket")). hasSigningRegion("eu-west-1"); assertThat(parse("s3://s3.amazonaws.com/bucket")). hasSigningRegion("us-east-1"); - assertThat(parse("s3://bucket.s3-eu-west-1.amazonaws.com")). + assertThat(parse("s3://bucket.s3.eu-west-1.amazonaws.com")). hasSigningRegion("eu-west-1"); assertThat(parse("s3://s3-tests.storage.yandexcloud.net")). @@ -151,13 +151,13 @@ public void checkRegionParsing() throws FileSystemException { @Test public void checkBrokenUrls() throws FileSystemException { - assertThat(parse("s3://s3-eu-west-1.amazonaws.com/s3-tests//big_file.iso")). - hasEndpoint("s3-eu-west-1.amazonaws.com"). + assertThat(parse("s3://s3.eu-west-1.amazonaws.com/s3-tests//big_file.iso")). + hasEndpoint("s3.eu-west-1.amazonaws.com"). hasPathPrefix("s3-tests"). hasPath("/big_file.iso"); - assertThat(parse("s3://s3-eu-west-1.amazonaws.com///////s3-tests///////big_file.iso")). - hasEndpoint("s3-eu-west-1.amazonaws.com"). + assertThat(parse("s3://s3.eu-west-1.amazonaws.com///////s3-tests///////big_file.iso")). + hasEndpoint("s3.eu-west-1.amazonaws.com"). hasPathPrefix("s3-tests"). hasPath("/big_file.iso"); @@ -202,7 +202,7 @@ public void checkCredentials() throws FileSystemException { hasType(FOLDER); assertThat(parse("s3://access:secret:cn-north-1@bucket.s3.amazonaws.com")). - hasEndpoint("s3-cn-north-1.amazonaws.com"). + hasEndpoint("s3.cn-north-1.amazonaws.com"). hasPathPrefix("bucket"). hasType(FOLDER). hasSigningRegion("cn-north-1");