Normalize the separator in resource names

See gh-44444
This commit is contained in:
Andy Wilkinson 2025-03-05 15:39:59 +00:00
parent 8e49a4e49a
commit 1f5b9de302
1 changed files with 5 additions and 4 deletions

View File

@ -113,13 +113,14 @@ class Resources {
}
private void register(String name, Resource resource) {
this.resources.put(name, resource);
String normalized = name.replace("\\", "/");
this.resources.put(normalized, resource);
if (Files.isDirectory(resource.path())) {
if (name.endsWith("/")) {
this.resources.put(name.substring(0, name.length() - 1), resource);
if (normalized.endsWith("/")) {
this.resources.put(normalized.substring(0, normalized.length() - 1), resource);
}
else {
this.resources.put(name + "/", resource);
this.resources.put(normalized + "/", resource);
}
}
}