diff --git a/application/src/main/java/run/halo/app/core/extension/reconciler/PluginReconciler.java b/application/src/main/java/run/halo/app/core/extension/reconciler/PluginReconciler.java index 8b0067460..b8cedd315 100644 --- a/application/src/main/java/run/halo/app/core/extension/reconciler/PluginReconciler.java +++ b/application/src/main/java/run/halo/app/core/extension/reconciler/PluginReconciler.java @@ -577,7 +577,6 @@ public class PluginReconciler implements Reconciler { return pluginPath.toString(); } - /** * Returns absolute plugin path. * if plugin path is absolute, use it directly in development mode. @@ -629,7 +628,11 @@ public class PluginReconciler implements Reconciler { if (StringUtils.isBlank(pathString)) { return null; } - return Paths.get(URI.create(pathString).getPath()); + String processedPathString = pathString; + if (processedPathString.startsWith("file:")) { + processedPathString = processedPathString.substring(7); + } + return Paths.get(processedPathString); } URI toUri(String pathString) { diff --git a/application/src/test/java/run/halo/app/core/extension/reconciler/PluginReconcilerTest.java b/application/src/test/java/run/halo/app/core/extension/reconciler/PluginReconcilerTest.java index 40a85f3e6..a540d1324 100644 --- a/application/src/test/java/run/halo/app/core/extension/reconciler/PluginReconcilerTest.java +++ b/application/src/test/java/run/halo/app/core/extension/reconciler/PluginReconcilerTest.java @@ -468,6 +468,14 @@ class PluginReconcilerTest { Path path = pluginReconciler.toPath("file:///path/to/file.txt"); assertThat(path).isNotNull(); assertThat(path.toString()).isEqualTo("/path/to/file.txt"); + + assertThat(pluginReconciler.toPath("C:\\Users\\faker\\halo\\plugins").toString()) + .isEqualTo("C:\\Users\\faker\\halo\\plugins"); + assertThat(pluginReconciler.toPath("C:/Users/faker/halo/plugins").toString()) + .isEqualTo("C:/Users/faker/halo/plugins"); + Path windowsPath = Paths.get("C:/Users/username/Documents/file.txt"); + assertThat(pluginReconciler.toPath("file://C:/Users/username/Documents/file.txt")) + .isEqualTo(windowsPath); } @Test