Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…/java/nio/file/Path.html#subpath-int-int- subpath shall return a relative path
  • Loading branch information
stefanofornari committed Mar 3, 2024
1 parent a197a93 commit d26c39a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/main/java/software/amazon/nio/spi/s3/S3Path.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,6 @@ public S3Path subpath(int beginIndex, int endIndex) {
}

var path = String.join(PATH_SEPARATOR, pathRepresentation.elements().subList(beginIndex, endIndex));
if (this.isAbsolute() && beginIndex == 0) {
path = PATH_SEPARATOR + path;
}

if (endIndex == size && !pathRepresentation.hasTrailingSeparator()) {
return from(path);
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/software/amazon/nio/spi/s3/S3PathTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ public void relativize() {
var bcd = fileSystem.getPath("b/c/d/");
var bcdObject = fileSystem.getPath("b/c/d/object");

assertFalse(root.relativize(ab).isAbsolute());

assertEquals(fileSystem.getPath(""), absoluteObject.relativize(absoluteObject));
assertEquals(fileSystem.getPath("../.."), abcd.relativize(ab));
assertEquals(fileSystem.getPath("e/"), abcd.relativize(abcde));
Expand Down

0 comments on commit d26c39a

Please sign in to comment.