mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8314569: (fs) Improve normalization of UnixPath for input with trailing slashes
Reviewed-by: alanb, bpb, rriggs
This commit is contained in:
parent
8b8182db59
commit
93188bd80c
1 changed files with 4 additions and 4 deletions
|
@ -36,7 +36,6 @@ import java.nio.file.ProviderMismatchException;
|
|||
import java.nio.file.WatchEvent;
|
||||
import java.nio.file.WatchKey;
|
||||
import java.nio.file.WatchService;
|
||||
import java.nio.file.spi.FileSystemProvider;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -90,8 +89,9 @@ class UnixPath implements Path {
|
|||
checkNotNul(input, c);
|
||||
prevChar = c;
|
||||
}
|
||||
if (prevChar == '/')
|
||||
return normalize(input, n, n - 1);
|
||||
if (prevChar == '/' && n > 1) {
|
||||
return input.substring(0, n - 1);
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ class UnixPath implements Path {
|
|||
return "/";
|
||||
StringBuilder sb = new StringBuilder(input.length());
|
||||
if (off > 0)
|
||||
sb.append(input.substring(0, off));
|
||||
sb.append(input, 0, off);
|
||||
char prevChar = 0;
|
||||
for (int i=off; i < n; i++) {
|
||||
char c = input.charAt(i);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue