Adapt Windows path handling fix to deal with Jetty
Update `NestedLocation` to deal with the fact that Jetty attempts to fix URLs. See gh-40549
This commit is contained in:
parent
7708ec7592
commit
8457fc333f
|
@ -107,11 +107,7 @@ public record NestedLocation(Path path, String nestedEntryName) {
|
||||||
|
|
||||||
private static Path asPath(String locationPath) {
|
private static Path asPath(String locationPath) {
|
||||||
return pathCache.computeIfAbsent(locationPath, (key) -> {
|
return pathCache.computeIfAbsent(locationPath, (key) -> {
|
||||||
if (isWindows() && locationPath.length() > 2 && locationPath.charAt(2) == ':') {
|
return Path.of((!isWindows()) ? locationPath : fixWindowsLocationPath(locationPath));
|
||||||
// Use the same logic as Java's internal WindowsUriSupport class
|
|
||||||
return Path.of(locationPath.substring(1));
|
|
||||||
}
|
|
||||||
return Path.of(locationPath);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,6 +115,18 @@ public record NestedLocation(Path path, String nestedEntryName) {
|
||||||
return File.separatorChar == '\\';
|
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() {
|
static void clearCache() {
|
||||||
locationCache.clear();
|
locationCache.clear();
|
||||||
pathCache.clear();
|
pathCache.clear();
|
||||||
|
|
Loading…
Reference in New Issue