Merge branch '3.2.x'

This commit is contained in:
Phillip Webb
2024-05-08 18:05:31 -07:00

View File

@@ -107,11 +107,7 @@ public record NestedLocation(Path path, String nestedEntryName) {
private static Path asPath(String locationPath) {
return pathCache.computeIfAbsent(locationPath, (key) -> {
if (isWindows() && locationPath.length() > 2 && locationPath.charAt(2) == ':') {
// Use the same logic as Java's internal WindowsUriSupport class
return Path.of(locationPath.substring(1));
}
return Path.of(locationPath);
return Path.of((!isWindows()) ? locationPath : fixWindowsLocationPath(locationPath));
});
}
@@ -119,6 +115,18 @@ public record NestedLocation(Path path, String nestedEntryName) {
return File.separatorChar == '\\';
}
private static String fixWindowsLocationPath(String locationPath) {
// Same logic as Java's internal WindowsUriSupport class
if (locationPath.length() > 2 && locationPath.charAt(2) == ':') {
return locationPath.substring(1);
}
// Deal with Jetty's org.eclipse.jetty.util.URIUtil#correctURI(URI)
if (locationPath.startsWith("///") && locationPath.charAt(4) == ':') {
return locationPath.substring(3);
}
return locationPath;
}
static void clearCache() {
locationCache.clear();
pathCache.clear();