From 71c9110232fbb25674866db09bcffc7050022fd2 Mon Sep 17 00:00:00 2001 From: Matthias Kurz Date: Fri, 20 Oct 2023 21:04:35 +0200 Subject: [PATCH] path separator in JAR file is always / It is not platform-dependent. --- src/main/java/org/webjars/WebJarExtractor.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/webjars/WebJarExtractor.java b/src/main/java/org/webjars/WebJarExtractor.java index 6e59389..80ee06f 100644 --- a/src/main/java/org/webjars/WebJarExtractor.java +++ b/src/main/java/org/webjars/WebJarExtractor.java @@ -40,6 +40,8 @@ public class WebJarExtractor { /** The bower.json file name. */ public static final String BOWER_JSON = "bower.json"; + private static final String JAR_PATH_DELIMITER = "/"; + private static final Logger log = LoggerFactory.getLogger(WebJarExtractor.class); private final ClassLoader classLoader; @@ -130,7 +132,7 @@ private void extractResourcesTo(@Nonnull final String webJarName, @Nonnull final } private static void extractResource(@Nonnull String webJarName, @Nonnull WebJarInfo webJarInfo, @Nullable File to, @Nonnull String webJarId, @Nonnull Resource resource, @Nonnull InputStream inputStream) { - final String prefix = String.format("%s%s%s%s%s", WEBJARS_PATH_PREFIX, File.separator, webJarName, File.separator, webJarInfo.getVersion() == null ? "" : String.format("%s%s", webJarInfo.getVersion(), File.separator)); + final String prefix = String.format("%s%s%s%s%s", WEBJARS_PATH_PREFIX, JAR_PATH_DELIMITER, webJarName, JAR_PATH_DELIMITER, webJarInfo.getVersion() == null ? "" : String.format("%s%s", webJarInfo.getVersion(), JAR_PATH_DELIMITER)); if (resource.getPath().startsWith(prefix)) { final String newPath = resource.getPath().substring(prefix.length()); final String relativeName = String.format("%s%s%s", webJarId, File.separator, newPath);