From f426f98db3e405306ae221c04bde361a12429679 Mon Sep 17 00:00:00 2001 From: Julieng50 Date: Sun, 17 Dec 2017 02:25:12 +0100 Subject: [PATCH] #185 : fix missing slash for jar file on Windows while creating new file system (#186) --- pf4j/src/main/java/org/pf4j/util/FileUtils.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pf4j/src/main/java/org/pf4j/util/FileUtils.java b/pf4j/src/main/java/org/pf4j/util/FileUtils.java index e3e8959..0c54e0a 100644 --- a/pf4j/src/main/java/org/pf4j/util/FileUtils.java +++ b/pf4j/src/main/java/org/pf4j/util/FileUtils.java @@ -43,6 +43,7 @@ import java.util.List; */ public class FileUtils { + private static final String SLASH = "/"; private static final Logger log = LoggerFactory.getLogger(FileUtils.class); public static List readLines(Path path, boolean ignoreComments) throws IOException { @@ -216,7 +217,11 @@ public class FileUtils { public static Path getPath(Path path, String first, String... more) throws IOException { URI uri = path.toUri(); if (isJarFile(path)) { - uri = URI.create("jar:file:" + path.toString().replace("\\", "/")); + String pathString = path.toString().replace("\\", SLASH); + if(!pathString.startsWith(SLASH)){ + pathString = SLASH + pathString; + } + uri = URI.create("jar:file:" + pathString); } return getPath(uri, first, more); -- 2.39.5