Skip to content

Commit

Permalink
path separator in JAR file is always /
Browse files Browse the repository at this point in the history
It is not platform-dependent.
  • Loading branch information
mkurz committed Oct 20, 2023
1 parent 1cb9198 commit 71c9110
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/org/webjars/WebJarExtractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 71c9110

Please sign in to comment.