From 1f5b9de3028f77ad965714e07a6e53ce1f3b71e7 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 5 Mar 2025 15:39:59 +0000 Subject: [PATCH] Normalize the separator in resource names See gh-44444 --- .../boot/testsupport/classpath/resources/Resources.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/resources/Resources.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/resources/Resources.java index 9d400b61e78..96e5011b3f2 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/resources/Resources.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/resources/Resources.java @@ -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); } } }