File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
main/java/software/amazon/nio/spi/s3
test/java/software/amazon/nio/spi/s3 Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -387,6 +387,10 @@ public S3Path normalize() {
387387 final var elements = pathRepresentation .elements ();
388388 final var realElements = new LinkedList <String >();
389389
390+ if (this .isAbsolute ()) {
391+ realElements .add (PATH_SEPARATOR );
392+ }
393+
390394 for (var element : elements ) {
391395 if (element .equals ("." )) {
392396 continue ;
Original file line number Diff line number Diff line change @@ -278,6 +278,18 @@ public void normalize() {
278278 assertEquals (fileSystem .getPath ("/dir3/" ), relativeDirectory .toAbsolutePath ().normalize ());
279279 }
280280
281+ @ Test
282+ public void normalizeAndIsAbsolute () {
283+ final S3Path pathRelative = S3Path .getPath (fileSystem , "foo/./baa/" );
284+ final S3Path pathAbsolute = S3Path .getPath (fileSystem , "/foo/./baa/" );
285+
286+ assertFalse (pathRelative .isAbsolute ());
287+ assertTrue (pathAbsolute .isAbsolute ());
288+
289+ assertFalse (pathRelative .normalize ().isAbsolute ());
290+ assertTrue (pathAbsolute .normalize ().isAbsolute ());
291+ }
292+
281293 @ Test
282294 public void resolve () {
283295 assertEquals (absoluteObject , root .resolve (absoluteObject ));
You can’t perform that action at this time.
0 commit comments