From f75bcbc33c75bdc71df6c5341e21a342b7572eae Mon Sep 17 00:00:00 2001 From: tburch Date: Mon, 23 Feb 2026 13:07:10 +0100 Subject: [PATCH 1/3] Fix path test on windows --- .../membrane/core/resolver/ResolverMapCombineTest.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/src/test/java/com/predic8/membrane/core/resolver/ResolverMapCombineTest.java b/core/src/test/java/com/predic8/membrane/core/resolver/ResolverMapCombineTest.java index b95b6fb06a..fdb6d810c8 100644 --- a/core/src/test/java/com/predic8/membrane/core/resolver/ResolverMapCombineTest.java +++ b/core/src/test/java/com/predic8/membrane/core/resolver/ResolverMapCombineTest.java @@ -63,7 +63,8 @@ void relativeWithSpacePlusFile() { @Test void fileSingleSlashPlusFile() { - assertEquals("file:/chi/gnat", combine("file:/chi/elm","gnat")); + assertEquals(wl("file:/C:/chi/gnat", + "file:/chi/gnat"), combine("file:/chi/elm","gnat")); } @Test @@ -195,7 +196,10 @@ void fileSingleSlashPlusFileSpace() { @Test void filePlusPathSpace() { - assertEquals("file:/cock%20lock", combine("file:/chi","cock lock")); + assertEquals(wl( + "file:/C:/cock%20lock", + "file:/cock%20lock"), + combine("file:/chi","cock lock")); } @Test From cfae984ee10097c6d6b8075a8c2153ab92d2dc31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6rdes?= Date: Tue, 24 Feb 2026 16:46:19 +0100 Subject: [PATCH 2/3] Normalize Windows drive handling in `OSUtil` and add detection of the active Windows drive. --- .../predic8/membrane/core/util/OSUtil.java | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/predic8/membrane/core/util/OSUtil.java b/core/src/main/java/com/predic8/membrane/core/util/OSUtil.java index c3aaefac0a..a8826b299f 100644 --- a/core/src/main/java/com/predic8/membrane/core/util/OSUtil.java +++ b/core/src/main/java/com/predic8/membrane/core/util/OSUtil.java @@ -18,12 +18,17 @@ import org.jetbrains.annotations.*; +import java.nio.file.Path; +import java.nio.file.Paths; + import static com.predic8.membrane.core.util.OSUtil.OS.*; public class OSUtil { public static final String OS_NAME_PROPERTY = "os.name"; + private static final String WINDOWS_DRIVE = detectWindowsDrive(); + public static boolean isWindows() { return System.getProperty(OS_NAME_PROPERTY,"").toLowerCase().contains("windows"); } @@ -49,9 +54,37 @@ public static String fixBackslashes(String s) { return s.replaceAll("\\\\", "/"); } - public static String wl(String windows, String linux) { + public static String wl(String windows, String linux) { if (OSUtil.isWindows()) - return windows; + return normalizeWindowsDrive(windows); return linux; } + + private static String detectWindowsDrive() { + if (!isWindows()) return "C:"; + + try { + Path root = Paths.get("").toAbsolutePath().getRoot(); // e.g. "D:\" + if (root == null) return "C:"; + String r = root.toString(); + return (r.length() >= 2 && r.charAt(1) == ':') ? r.substring(0, 2) : "C:"; + } catch (Exception ignored) { + return "C:"; + } + } + + private static String normalizeWindowsDrive(String s) { + if (!isWindows() || s == null || "C:".equals(WINDOWS_DRIVE)) return s; + + if (s.startsWith("file:/C:")) { + return "file:/" + WINDOWS_DRIVE + s.substring("file:/C:".length()); + } + if (s.startsWith("C:\\")) { + return WINDOWS_DRIVE + s.substring(2); + } + if (s.startsWith("C:/")) { + return WINDOWS_DRIVE + s.substring(2); + } + return s; + } } From a625c00f9e8a1c9d4c82cbd799f5c4c16f92d17b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6rdes?= Date: Tue, 24 Feb 2026 16:46:35 +0100 Subject: [PATCH 3/3] . --- core/src/main/java/com/predic8/membrane/core/util/OSUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/com/predic8/membrane/core/util/OSUtil.java b/core/src/main/java/com/predic8/membrane/core/util/OSUtil.java index a8826b299f..2bfb823576 100644 --- a/core/src/main/java/com/predic8/membrane/core/util/OSUtil.java +++ b/core/src/main/java/com/predic8/membrane/core/util/OSUtil.java @@ -64,7 +64,7 @@ private static String detectWindowsDrive() { if (!isWindows()) return "C:"; try { - Path root = Paths.get("").toAbsolutePath().getRoot(); // e.g. "D:\" + Path root = Paths.get("").toAbsolutePath().getRoot(); if (root == null) return "C:"; String r = root.toString(); return (r.length() >= 2 && r.charAt(1) == ':') ? r.substring(0, 2) : "C:";