Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Commit

Permalink
Fix GetRelativePath with different volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
BrennanConroy committed Sep 11, 2015
1 parent 91d1193 commit 8ec9f73
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/Microsoft.Dnx.Runtime/NuGet/Utility/PathUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ public static string GetRelativePath(string path1, string path2, char separator)
if (Microsoft.Dnx.Runtime.RuntimeEnvironmentHelper.IsWindows)
{
compare = StringComparison.OrdinalIgnoreCase;
// check if paths are on the same volume
if (!string.Equals(Path.GetPathRoot(path1), Path.GetPathRoot(path2)))
{
// on different volumes, "relative" path is just path2
return path2;
}
}
else
{
Expand Down
5 changes: 4 additions & 1 deletion test/Microsoft.Dnx.Runtime.Tests/PathUtilityFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ public static IEnumerable<object[]> FolderPaths
new object[] { "", "C:/folder/app", "C:/folder/app" },
new object[] { "app/", "C:/folder/app", "C:/folder/app/" },
new object[] { "../diff/app/", "C:/folder/app", "C:/diff/app/" },
new object[] { "../folder1/file", "C:\\folder\\file", "C:\\folder1\\file" }
new object[] { "../folder1/file", "C:\\folder\\file", "C:\\folder1\\file" },
new object[] { "H:\\folder\\file", "C:\\folder\\file", "H:\\folder\\file" },
new object[] { "folder/file", "C:\\", "C:\\folder\\file" },
new object[] { "..\\", "C:\\folder\\file", "C:\\" }
});
}
else
Expand Down

0 comments on commit 8ec9f73

Please sign in to comment.