Skip to content

Commit 98ca3c7

Browse files
committed
Ignore trailing slashes in FileUtils.PathEquals()
1 parent de51bc2 commit 98ca3c7

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Common/Storage/FileUtils.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ public static bool PathEquals(string? path1, string? path2)
2525
{
2626
try
2727
{
28-
path1 = path1?.To(Path.GetFullPath);
29-
path2 = path2?.To(Path.GetFullPath);
28+
path1 = path1?.To(Path.GetFullPath).TrimEnd(Path.DirectorySeparatorChar);
29+
path2 = path2?.To(Path.GetFullPath).TrimEnd(Path.DirectorySeparatorChar);
3030
}
3131
catch (ArgumentException) {}
3232

src/UnitTests/Storage/FileUtilsTest.cs

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ public void TestPathEqualsWorkingDirectory()
2727
public void TestPathEqualsDirectorySeparator()
2828
=> FileUtils.PathEquals("abc/def", Path.Combine("abc", "def")).Should().BeTrue();
2929

30+
[Fact]
31+
public void TestPathEqualsTrailingSLash()
32+
=> FileUtils.PathEquals(Locations.InstallBase, Locations.InstallBase + "/").Should().BeTrue();
33+
3034
[SkippableFact]
3135
public void TestPathEqualsCaseSensitive()
3236
{

0 commit comments

Comments
 (0)