diff --git a/src/main/java/org/kiwiproject/jar/KiwiJars.java b/src/main/java/org/kiwiproject/jar/KiwiJars.java index 0b3ad999..bb19dc63 100644 --- a/src/main/java/org/kiwiproject/jar/KiwiJars.java +++ b/src/main/java/org/kiwiproject/jar/KiwiJars.java @@ -27,6 +27,7 @@ import java.util.Set; import java.util.function.Predicate; import java.util.jar.Manifest; +import java.util.regex.Pattern; import java.util.stream.StreamSupport; /** @@ -36,6 +37,8 @@ @UtilityClass public class KiwiJars { + private static final String QUOTED_FILE_SEPARATOR = Pattern.quote(File.separator); + /** * Get the path components of the JAR file path that the given class lives in, or an empty list if the path * components could not be obtained. @@ -54,7 +57,7 @@ public static List getPathComponents(Class classInJar) { var encodedJarPath = codeSource.getLocation().getPath(); var decodedJarPath = URLDecoder.decode(encodedJarPath, StandardCharsets.UTF_8); - return newArrayList(decodedJarPath.trim().split(File.separator)); + return newArrayList(decodedJarPath.trim().split(QUOTED_FILE_SEPARATOR)); } catch (Exception e) { return logExceptionAndReturnEmptyList(e, classInJar); }