Skip to content

Commit 26b8e97

Browse files
authored
fix: FakeNavigationManager can't handle umlauts (#952)
* Fix case when Uri does not have Absolute Path. In the real implementation this works fine. But not when unit-testing. This fixes that issue. * Fix unit test. Change GetNewAbsoluteUri * Updated CHANGELOG.md * Test case for umlauts. Rephrase CHANGELOG. Fixes according to comments on PR. * Add 'Fixed' subtitle in changelog.
1 parent 2f5f559 commit 26b8e97

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ All notable changes to **bUnit** will be documented in this file. The project ad
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- Added support in `FakeNavigationManager` to handle umlauts.
12+
913
## [1.13.5] - 2022-12-16
1014

1115
This release contains a bunch of small tweaks and fixes.

src/bunit.web/TestDoubles/NavigationManager/FakeNavigationManager.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,8 @@ protected override void HandleLocationChangingHandlerException(Exception ex, Loc
142142
#endif
143143

144144
private URI GetNewAbsoluteUri(string uri)
145-
=> URI.IsWellFormedUriString(uri, UriKind.Relative)
146-
? ToAbsoluteUri(uri)
147-
: new URI(uri, UriKind.Absolute);
145+
=> new URI(uri, UriKind.RelativeOrAbsolute).IsAbsoluteUri
146+
? new URI(uri, UriKind.RelativeOrAbsolute) : ToAbsoluteUri(uri);
148147

149148
private bool HasDifferentBaseUri(URI absoluteUri)
150149
=> URI.Compare(

tests/bunit.web.tests/TestDoubles/NavigationManager/FakeNavigationManagerTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public void Test002()
3333
[InlineData("")]
3434
[InlineData("/")]
3535
[InlineData("/foo")]
36+
[InlineData("/#Storstädning")]
37+
[InlineData("/#åäö")]
3638
public void Test003(string uri)
3739
{
3840
var sut = CreateFakeNavigationManager();

0 commit comments

Comments
 (0)