Skip to content

Commit 342b273

Browse files
authored
BlazorWebView: ignore query‑string dots in IsBaseOfPage
1 parent e2c79eb commit 342b273

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/BlazorWebView/src/Maui/Extensions/UriExtensions.cs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,21 @@ namespace Microsoft.AspNetCore.Components.WebView.Maui
55
{
66
internal static class UriExtensions
77
{
8-
internal static bool IsBaseOfPage(this Uri baseUri, string? uriString)
9-
{
10-
if (Path.HasExtension(uriString))
11-
{
12-
// If the path ends in a file extension, it's not referring to a page.
13-
return false;
14-
}
15-
16-
var uri = new Uri(uriString!);
17-
return baseUri.IsBaseOf(uri);
18-
}
8+
internal static bool IsBaseOfPage(this Uri baseUri, string? uriString)
9+
{
10+
if (string.IsNullOrWhiteSpace(uriString))
11+
return false;
12+
13+
if (!Uri.TryCreate(uriString, UriKind.Absolute, out var uri))
14+
return false;
15+
16+
if (uri.Scheme is not ("http" or "https"))
17+
return false;
18+
19+
if (Path.HasExtension(uri.AbsolutePath))
20+
return false;
21+
22+
return baseUri.IsBaseOf(uri);
23+
}
1924
}
2025
}

0 commit comments

Comments
 (0)