File tree 1 file changed +16
-11
lines changed
src/BlazorWebView/src/Maui/Extensions 1 file changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -5,16 +5,21 @@ namespace Microsoft.AspNetCore.Components.WebView.Maui
5
5
{
6
6
internal static class UriExtensions
7
7
{
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
+ }
19
24
}
20
25
}
You can’t perform that action at this time.
0 commit comments