diff --git a/src/libraries/System.Private.Uri/src/System/Uri.cs b/src/libraries/System.Private.Uri/src/System/Uri.cs index d1d27484e82f76..5418d8d0d5e449 100644 --- a/src/libraries/System.Private.Uri/src/System/Uri.cs +++ b/src/libraries/System.Private.Uri/src/System/Uri.cs @@ -1545,7 +1545,7 @@ public override int GetHashCode() string remoteUrl = info.RemoteUrl ??= GetParts(components, UriFormat.SafeUnescaped); - if (IsUncOrDosPath) + if (IsFile) { return StringComparer.OrdinalIgnoreCase.GetHashCode(remoteUrl); } diff --git a/src/libraries/System.Private.Uri/tests/FunctionalTests/UriMethodsTests.cs b/src/libraries/System.Private.Uri/tests/FunctionalTests/UriMethodsTests.cs index b07938a84ebb73..5b5b7fbbaf03ef 100644 --- a/src/libraries/System.Private.Uri/tests/FunctionalTests/UriMethodsTests.cs +++ b/src/libraries/System.Private.Uri/tests/FunctionalTests/UriMethodsTests.cs @@ -347,6 +347,9 @@ public static IEnumerable Equals_TestData() yield return new object[] { new Uri("file://C:/path1/path2/file"), new Uri("http://domain.com"), false }; yield return new object[] { new Uri("file://C:/path1/path2/file"), new Uri(@"\\server\path1\path2\file"), false }; + // UNC paths that normalize to the same value as a regular file: URI + yield return new object[] { new Uri("\\\\\u202a"), new Uri("file:///"), true }; + // UNC share paths yield return new object[] { new Uri(@"\\server\sharepath\path\file"), new Uri(@"\\server\sharepath\path\file"), true }; yield return new object[] { new Uri(@"\\server\sharepath\path\file"), new Uri(@"\\server1\sharepath\path\file"), false };