Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit d7ba679

Browse files
committed
merge PR #100 fix relative uri encoding in S3Path
thx @sbeimin
1 parent a024ac7 commit d7ba679

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/main/java/com/upplication/s3fs/S3Path.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ public URI toUri() {
465465
return URI.create("s3://" + normalizeURI(builder.toString()));
466466
}
467467
else {
468-
return URI.create(this.uri);
468+
return URI.create(uri);
469469
}
470470
}
471471

src/test/java/com/upplication/s3fs/Path/ToUriTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ public void toUriWithEndSlash() {
5757
assertEquals(S3_GLOBAL_URI_TEST + "bucket/folder/", s3Path.toUri().toString());
5858
}
5959

60+
@Test
61+
public void toUriWithSpaces() {
62+
S3Path s3Path = getPath("/bucket/with spaces");
63+
64+
assertEquals(S3_GLOBAL_URI_TEST.resolve("bucket/with%20spaces") , s3Path.toUri());
65+
}
66+
6067
@Test
6168
public void toUriWithNotEndSlash() {
6269
S3Path s3Path = getPath("/bucket/file");
@@ -72,6 +79,14 @@ public void toUriRelative() {
7279
assertEquals(URI.create("bla"), path.toUri());
7380
}
7481

82+
@Test
83+
public void toUriRelativeWithSpaces() {
84+
S3FileSystem fileSystem = s3fsProvider.getFileSystem(S3_GLOBAL_URI_TEST);
85+
86+
S3Path path = new S3Path(fileSystem, "with space");
87+
assertEquals(URI.create("with%20space"), path.toUri());
88+
}
89+
7590
@Test
7691
public void toUriBucketWithoutEndSlash() {
7792
S3Path s3Path = getPath("/bucket");

0 commit comments

Comments
 (0)