This is an automated email from the ASF dual-hosted git repository. elharo pushed a commit to branch fix/pathtool-windows-drive-regex in repository https://gitbox.apache.org/repos/asf/maven-shared-utils.git
commit d7d179bfaf31e59aef0dee230427ff1265e70159 Author: Elliotte Rusty Harold <[email protected]> AuthorDate: Wed Jul 1 08:34:02 2026 -0400 Add failing test: PathTool Windows drive letter regex --- src/test/java/org/apache/maven/shared/utils/PathToolTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/test/java/org/apache/maven/shared/utils/PathToolTest.java b/src/test/java/org/apache/maven/shared/utils/PathToolTest.java index 3153765..c93e586 100644 --- a/src/test/java/org/apache/maven/shared/utils/PathToolTest.java +++ b/src/test/java/org/apache/maven/shared/utils/PathToolTest.java @@ -102,6 +102,15 @@ public class PathToolTest { assertEquals("", PathTool.getRelativePath("/usr/local/java/bin/java.sh", "/usr/local/")); } + @Test + public void testGetRelativeFilePathWithDifferentWindowsDrives() { + // Tests that the regex fix at line 146 correctly strips a leading backslash + // before a Windows drive letter. The old regex "^\\[a-zA-Z]:" matched the + // literal string "[a-zA-Z]:" instead of a backslash + drive letter. + // Different drives with leading backslash should return null. + assertNull(PathTool.getRelativeFilePath("\\C:\\usr\\local", "\\D:\\usr\\local\\java\\bin")); + } + @Test public void testUppercaseDrive() { assertNull(PathTool.uppercaseDrive(null));
