Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/org/apache/maven/shared/utils/PathTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,14 @@ public static String getRelativeFilePath(final String oldPath, final String newP
&& (!toPath.substring(0, 1).equals(fromPath.substring(0, 1)))) {
// they both have drive path element but they dont match, no
// relative path
return null;
return "";
}

if ((toPath.startsWith(":", 1) && !fromPath.startsWith(":", 1))
|| (!toPath.startsWith(":", 1) && fromPath.startsWith(":", 1))) {
// one has a drive path element and the other doesnt, no relative
// path.
return null;
return "";
}

String resultPath = buildRelativePath(toPath, fromPath, File.separatorChar);
Expand Down
4 changes: 4 additions & 0 deletions src/test/java/org/apache/maven/shared/utils/PathToolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public void testGetRelativeFilePathNonWindows() {
assertEquals("../../bin", PathTool.getRelativeFilePath("/usr/local/", "/bin"));

assertEquals("../usr/local/", PathTool.getRelativeFilePath("/bin", "/usr/local/"));

assertEquals("", PathTool.getRelativeFilePath("c:/usr/local", "d:/java/bin"));
}

@Test
Expand Down Expand Up @@ -85,6 +87,8 @@ public void testGetRelativeFilePathWindows() {
assertEquals("..\\..\\bin", PathTool.getRelativeFilePath("c:\\usr\\local\\", "c:\\bin"));

assertEquals("..\\usr\\local\\", PathTool.getRelativeFilePath("c:\\bin", "c:\\usr\\local\\"));

assertEquals("", PathTool.getRelativeFilePath("c:\\usr\\local", "d:\\java\\bin"));
}

@Test
Expand Down
Loading