|
1 | 1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | 3 |
|
| 4 | +using System; |
4 | 5 | using System.Buffers; |
5 | 6 | using System.Diagnostics; |
6 | 7 | using System.Net.Http; |
@@ -84,6 +85,21 @@ public void ToBaseRelativePath_ThrowsForInvalidBaseRelativePaths(string baseUri, |
84 | 85 | ex.Message); |
85 | 86 | } |
86 | 87 |
|
| 88 | + [Fact] |
| 89 | + public void ToBaseRelativePath_HonorsConfiguredPathBaseComparison() |
| 90 | + { |
| 91 | + var navigationManager = new TestNavigationManager("https://example.com/dashboard/", "https://example.com/dashboard/"); |
| 92 | + |
| 93 | + var ex = Assert.Throws<ArgumentException>(() => navigationManager.ToBaseRelativePath("https://example.com/DaShBoArD")); |
| 94 | + Assert.Equal("The URI 'https://example.com/DaShBoArD' is not contained by the base URI 'https://example.com/dashboard/'.", ex.Message); |
| 95 | + |
| 96 | + navigationManager.SetPathBaseComparison(StringComparison.OrdinalIgnoreCase); |
| 97 | + |
| 98 | + var result = navigationManager.ToBaseRelativePath("https://example.com/DaShBoArD"); |
| 99 | + |
| 100 | + Assert.Equal(string.Empty, result); |
| 101 | + } |
| 102 | + |
87 | 103 | [Theory] |
88 | 104 | [InlineData("scheme://host/?full%20name=Bob%20Joe&age=42", "scheme://host/?full%20name=John%20Doe&age=42")] |
89 | 105 | [InlineData("scheme://host/?fUlL%20nAmE=Bob%20Joe&AgE=42", "scheme://host/?full%20name=John%20Doe&AgE=42")] |
@@ -906,6 +922,11 @@ public TestNavigationManager(string baseUri = null, string uri = null) |
906 | 922 | public async Task<bool> RunNotifyLocationChangingAsync(string uri, string state, bool isNavigationIntercepted) |
907 | 923 | => await NotifyLocationChangingAsync(uri, state, isNavigationIntercepted); |
908 | 924 |
|
| 925 | + public void SetPathBaseComparison(StringComparison comparison) |
| 926 | + { |
| 927 | + PathBaseComparison = comparison; |
| 928 | + } |
| 929 | + |
909 | 930 | protected override void NavigateToCore(string uri, bool forceLoad) |
910 | 931 | { |
911 | 932 | throw new System.NotImplementedException(); |
|
0 commit comments