Skip to content

Commit 1f5b9de

Browse files
committed
Normalize the separator in resource names
See gh-44444
1 parent 8e49a4e commit 1f5b9de

File tree

1 file changed

+5
-4
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/resources

1 file changed

+5
-4
lines changed

Diff for: spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/resources/Resources.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,14 @@ private void register(String name, Path resourcePath, boolean additional) {
113113
}
114114

115115
private void register(String name, Resource resource) {
116-
this.resources.put(name, resource);
116+
String normalized = name.replace("\\", "/");
117+
this.resources.put(normalized, resource);
117118
if (Files.isDirectory(resource.path())) {
118-
if (name.endsWith("/")) {
119-
this.resources.put(name.substring(0, name.length() - 1), resource);
119+
if (normalized.endsWith("/")) {
120+
this.resources.put(normalized.substring(0, normalized.length() - 1), resource);
120121
}
121122
else {
122-
this.resources.put(name + "/", resource);
123+
this.resources.put(normalized + "/", resource);
123124
}
124125
}
125126
}

0 commit comments

Comments
 (0)