Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Microsoft.Maui-dev.sln
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{A9C514B9
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiBlazorWebView.DeviceTests", "src\BlazorWebView\tests\DeviceTests\MauiBlazorWebView.DeviceTests.csproj", "{5FEA7500-0ACE-4C26-9A7B-2EB3958CBBC6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiBlazorWebView.UnitTests", "src\BlazorWebView\tests\MauiBlazorWebView.UnitTests\MauiBlazorWebView.UnitTests.csproj", "{00E708AA-402D-4BB5-AD88-348274F8E1DF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SharedSource", "SharedSource", "{4F2926C8-43AB-4328-A735-D9EAD699F81D}"
ProjectSection(SolutionItems) = preProject
src\BlazorWebView\src\SharedSource\AutoCloseOnReadCompleteStream.cs = src\BlazorWebView\src\SharedSource\AutoCloseOnReadCompleteStream.cs
Expand Down Expand Up @@ -463,6 +465,10 @@ Global
{5FEA7500-0ACE-4C26-9A7B-2EB3958CBBC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5FEA7500-0ACE-4C26-9A7B-2EB3958CBBC6}.Release|Any CPU.Build.0 = Release|Any CPU
{5FEA7500-0ACE-4C26-9A7B-2EB3958CBBC6}.Release|Any CPU.Deploy.0 = Release|Any CPU
{00E708AA-402D-4BB5-AD88-348274F8E1DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00E708AA-402D-4BB5-AD88-348274F8E1DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00E708AA-402D-4BB5-AD88-348274F8E1DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00E708AA-402D-4BB5-AD88-348274F8E1DF}.Release|Any CPU.Build.0 = Release|Any CPU
{5B56A734-D53C-4635-A53E-F889FCFCDD66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B56A734-D53C-4635-A53E-F889FCFCDD66}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B56A734-D53C-4635-A53E-F889FCFCDD66}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
Expand Down Expand Up @@ -746,6 +752,7 @@ Global
{71FFE8BF-EBE4-4078-8484-86C6EA685D14} = {50C758FE-4E10-409A-94F5-A75480960864}
{A9C514B9-1EE2-4A12-8E8A-CE16D87545C3} = {1614D1A4-5C3D-4D5B-8C89-426E37A564EF}
{5FEA7500-0ACE-4C26-9A7B-2EB3958CBBC6} = {A9C514B9-1EE2-4A12-8E8A-CE16D87545C3}
{00E708AA-402D-4BB5-AD88-348274F8E1DF} = {A9C514B9-1EE2-4A12-8E8A-CE16D87545C3}
{4F2926C8-43AB-4328-A735-D9EAD699F81D} = {ED7F28E0-D0AF-417D-983D-3D874EEE8554}
{5B56A734-D53C-4635-A53E-F889FCFCDD66} = {C564DDD6-DE79-45CD-88EA-3F690481572A}
{E8728693-3537-4007-A4DB-9F9634548755} = {E8AD265B-3C67-4640-AC58-A522F9FB3361}
Expand Down
3 changes: 2 additions & 1 deletion Microsoft.Maui-mac.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"src\\BlazorWebView\\samples\\WebViewAppShared\\WebViewAppShared.csproj",
"src\\BlazorWebView\\src\\Maui\\Microsoft.AspNetCore.Components.WebView.Maui.csproj",
"src\\BlazorWebView\\tests\\DeviceTests\\MauiBlazorWebView.DeviceTests.csproj",
"src\\BlazorWebView\\tests\\MauiBlazorWebView.UnitTests\\MauiBlazorWebView.UnitTests.csproj",
"src\\Controls\\Foldable\\src\\Controls.Foldable.csproj",
"src\\Controls\\Maps\\src\\Controls.Maps.csproj",
"src\\Controls\\samples\\Controls.Sample.Profiling\\Maui.Controls.Sample.Profiling.csproj",
Expand Down Expand Up @@ -71,4 +72,4 @@
"src\\Workload\\Microsoft.NET.Sdk.Maui.Manifest\\Microsoft.NET.Sdk.Maui.Manifest.csproj"
]
}
}
}
7 changes: 7 additions & 0 deletions Microsoft.Maui-vscode.sln
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{A9C514B9
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiBlazorWebView.DeviceTests", "src\BlazorWebView\tests\DeviceTests\MauiBlazorWebView.DeviceTests.csproj", "{5FEA7500-0ACE-4C26-9A7B-2EB3958CBBC6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiBlazorWebView.UnitTests", "src\BlazorWebView\tests\MauiBlazorWebView.UnitTests\MauiBlazorWebView.UnitTests.csproj", "{00E708AA-402D-4BB5-AD88-348274F8E1DF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SharedSource", "SharedSource", "{4F2926C8-43AB-4328-A735-D9EAD699F81D}"
ProjectSection(SolutionItems) = preProject
src\BlazorWebView\src\SharedSource\AutoCloseOnReadCompleteStream.cs = src\BlazorWebView\src\SharedSource\AutoCloseOnReadCompleteStream.cs
Expand Down Expand Up @@ -414,6 +416,10 @@ Global
{5FEA7500-0ACE-4C26-9A7B-2EB3958CBBC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5FEA7500-0ACE-4C26-9A7B-2EB3958CBBC6}.Release|Any CPU.Build.0 = Release|Any CPU
{5FEA7500-0ACE-4C26-9A7B-2EB3958CBBC6}.Release|Any CPU.Deploy.0 = Release|Any CPU
{00E708AA-402D-4BB5-AD88-348274F8E1DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00E708AA-402D-4BB5-AD88-348274F8E1DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00E708AA-402D-4BB5-AD88-348274F8E1DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00E708AA-402D-4BB5-AD88-348274F8E1DF}.Release|Any CPU.Build.0 = Release|Any CPU
{5B56A734-D53C-4635-A53E-F889FCFCDD66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B56A734-D53C-4635-A53E-F889FCFCDD66}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B56A734-D53C-4635-A53E-F889FCFCDD66}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
Expand Down Expand Up @@ -659,6 +665,7 @@ Global
{71FFE8BF-EBE4-4078-8484-86C6EA685D14} = {50C758FE-4E10-409A-94F5-A75480960864}
{A9C514B9-1EE2-4A12-8E8A-CE16D87545C3} = {1614D1A4-5C3D-4D5B-8C89-426E37A564EF}
{5FEA7500-0ACE-4C26-9A7B-2EB3958CBBC6} = {A9C514B9-1EE2-4A12-8E8A-CE16D87545C3}
{00E708AA-402D-4BB5-AD88-348274F8E1DF} = {A9C514B9-1EE2-4A12-8E8A-CE16D87545C3}
{4F2926C8-43AB-4328-A735-D9EAD699F81D} = {ED7F28E0-D0AF-417D-983D-3D874EEE8554}
{5B56A734-D53C-4635-A53E-F889FCFCDD66} = {C564DDD6-DE79-45CD-88EA-3F690481572A}
{E8728693-3537-4007-A4DB-9F9634548755} = {E8AD265B-3C67-4640-AC58-A522F9FB3361}
Expand Down
3 changes: 2 additions & 1 deletion Microsoft.Maui-windows.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"src\\BlazorWebView\\src\\WindowsForms\\Microsoft.AspNetCore.Components.WebView.WindowsForms.csproj",
"src\\BlazorWebView\\src\\Wpf\\Microsoft.AspNetCore.Components.WebView.Wpf.csproj",
"src\\BlazorWebView\\tests\\DeviceTests\\MauiBlazorWebView.DeviceTests.csproj",
"src\\BlazorWebView\\tests\\MauiBlazorWebView.UnitTests\\MauiBlazorWebView.UnitTests.csproj",
"src\\Controls\\Foldable\\src\\Controls.Foldable.csproj",
"src\\Controls\\Maps\\src\\Controls.Maps.csproj",
"src\\Controls\\samples\\Controls.Sample.Profiling\\Maui.Controls.Sample.Profiling.csproj",
Expand Down Expand Up @@ -88,4 +89,4 @@
"src\\Workload\\Microsoft.NET.Sdk.Maui.Manifest\\Microsoft.NET.Sdk.Maui.Manifest.csproj"
]
}
}
}
7 changes: 7 additions & 0 deletions Microsoft.Maui.LegacyControlGallery.sln
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{A9C514B9
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiBlazorWebView.DeviceTests", "src\BlazorWebView\tests\DeviceTests\MauiBlazorWebView.DeviceTests.csproj", "{5FEA7500-0ACE-4C26-9A7B-2EB3958CBBC6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiBlazorWebView.UnitTests", "src\BlazorWebView\tests\MauiBlazorWebView.UnitTests\MauiBlazorWebView.UnitTests.csproj", "{00E708AA-402D-4BB5-AD88-348274F8E1DF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SharedSource", "SharedSource", "{4F2926C8-43AB-4328-A735-D9EAD699F81D}"
ProjectSection(SolutionItems) = preProject
src\BlazorWebView\src\SharedSource\AutoCloseOnReadCompleteStream.cs = src\BlazorWebView\src\SharedSource\AutoCloseOnReadCompleteStream.cs
Expand Down Expand Up @@ -456,6 +458,10 @@ Global
{5FEA7500-0ACE-4C26-9A7B-2EB3958CBBC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5FEA7500-0ACE-4C26-9A7B-2EB3958CBBC6}.Release|Any CPU.Build.0 = Release|Any CPU
{5FEA7500-0ACE-4C26-9A7B-2EB3958CBBC6}.Release|Any CPU.Deploy.0 = Release|Any CPU
{00E708AA-402D-4BB5-AD88-348274F8E1DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00E708AA-402D-4BB5-AD88-348274F8E1DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00E708AA-402D-4BB5-AD88-348274F8E1DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00E708AA-402D-4BB5-AD88-348274F8E1DF}.Release|Any CPU.Build.0 = Release|Any CPU
{5B56A734-D53C-4635-A53E-F889FCFCDD66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B56A734-D53C-4635-A53E-F889FCFCDD66}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B56A734-D53C-4635-A53E-F889FCFCDD66}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
Expand Down Expand Up @@ -737,6 +743,7 @@ Global
{71FFE8BF-EBE4-4078-8484-86C6EA685D14} = {50C758FE-4E10-409A-94F5-A75480960864}
{A9C514B9-1EE2-4A12-8E8A-CE16D87545C3} = {1614D1A4-5C3D-4D5B-8C89-426E37A564EF}
{5FEA7500-0ACE-4C26-9A7B-2EB3958CBBC6} = {A9C514B9-1EE2-4A12-8E8A-CE16D87545C3}
{00E708AA-402D-4BB5-AD88-348274F8E1DF} = {A9C514B9-1EE2-4A12-8E8A-CE16D87545C3}
{4F2926C8-43AB-4328-A735-D9EAD699F81D} = {ED7F28E0-D0AF-417D-983D-3D874EEE8554}
{5B56A734-D53C-4635-A53E-F889FCFCDD66} = {C564DDD6-DE79-45CD-88EA-3F690481572A}
{E8728693-3537-4007-A4DB-9F9634548755} = {E8AD265B-3C67-4640-AC58-A522F9FB3361}
Expand Down
7 changes: 7 additions & 0 deletions Microsoft.Maui.sln
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{A9C514B9
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiBlazorWebView.DeviceTests", "src\BlazorWebView\tests\DeviceTests\MauiBlazorWebView.DeviceTests.csproj", "{5FEA7500-0ACE-4C26-9A7B-2EB3958CBBC6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiBlazorWebView.UnitTests", "src\BlazorWebView\tests\MauiBlazorWebView.UnitTests\MauiBlazorWebView.UnitTests.csproj", "{00E708AA-402D-4BB5-AD88-348274F8E1DF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SharedSource", "SharedSource", "{4F2926C8-43AB-4328-A735-D9EAD699F81D}"
ProjectSection(SolutionItems) = preProject
src\BlazorWebView\src\SharedSource\AutoCloseOnReadCompleteStream.cs = src\BlazorWebView\src\SharedSource\AutoCloseOnReadCompleteStream.cs
Expand Down Expand Up @@ -469,6 +471,10 @@ Global
{5FEA7500-0ACE-4C26-9A7B-2EB3958CBBC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5FEA7500-0ACE-4C26-9A7B-2EB3958CBBC6}.Release|Any CPU.Build.0 = Release|Any CPU
{5FEA7500-0ACE-4C26-9A7B-2EB3958CBBC6}.Release|Any CPU.Deploy.0 = Release|Any CPU
{00E708AA-402D-4BB5-AD88-348274F8E1DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00E708AA-402D-4BB5-AD88-348274F8E1DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00E708AA-402D-4BB5-AD88-348274F8E1DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00E708AA-402D-4BB5-AD88-348274F8E1DF}.Release|Any CPU.Build.0 = Release|Any CPU
{5B56A734-D53C-4635-A53E-F889FCFCDD66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B56A734-D53C-4635-A53E-F889FCFCDD66}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B56A734-D53C-4635-A53E-F889FCFCDD66}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
Expand Down Expand Up @@ -751,6 +757,7 @@ Global
{71FFE8BF-EBE4-4078-8484-86C6EA685D14} = {50C758FE-4E10-409A-94F5-A75480960864}
{A9C514B9-1EE2-4A12-8E8A-CE16D87545C3} = {1614D1A4-5C3D-4D5B-8C89-426E37A564EF}
{5FEA7500-0ACE-4C26-9A7B-2EB3958CBBC6} = {A9C514B9-1EE2-4A12-8E8A-CE16D87545C3}
{00E708AA-402D-4BB5-AD88-348274F8E1DF} = {A9C514B9-1EE2-4A12-8E8A-CE16D87545C3}
{4F2926C8-43AB-4328-A735-D9EAD699F81D} = {ED7F28E0-D0AF-417D-983D-3D874EEE8554}
{5B56A734-D53C-4635-A53E-F889FCFCDD66} = {C564DDD6-DE79-45CD-88EA-3F690481572A}
{E8728693-3537-4007-A4DB-9F9634548755} = {E8AD265B-3C67-4640-AC58-A522F9FB3361}
Expand Down
1 change: 1 addition & 0 deletions eng/cake/dotnet.cake
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ Task("dotnet-test")
"**/Resizetizer.UnitTests.csproj",
"**/Graphics.Tests.csproj",
"**/Compatibility.Core.UnitTests.csproj",
"**/MauiBlazorWebView.UnitTests.csproj",
};

var success = true;
Expand Down
1 change: 1 addition & 0 deletions eng/helix.proj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<XUnitProject Include="$(RepoRoot)src/Essentials/test/UnitTests/Essentials.UnitTests.csproj" />
<XUnitProject Include="$(RepoRoot)src/AI/tests/Essentials.AI.UnitTests/Essentials.AI.UnitTests.csproj" />
<XUnitProject Include="$(RepoRoot)src/Graphics/tests/Graphics.Tests/Graphics.Tests.csproj" />
<XUnitProject Include="$(RepoRoot)src/BlazorWebView/tests/MauiBlazorWebView.UnitTests/MauiBlazorWebView.UnitTests.csproj" />
</ItemGroup>

<!-- Prepare the staging directory for MSBuild test payloads - runs early during Restore -->
Expand Down
27 changes: 17 additions & 10 deletions src/BlazorWebView/src/Maui/Extensions/UriExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
using System;
using System.IO;

namespace Microsoft.AspNetCore.Components.WebView.Maui
namespace Microsoft.AspNetCore.Components.WebView.Maui;

internal static class UriExtensions
{
internal static class UriExtensions
internal static bool IsBaseOfPage(this Uri baseUri, string? uriString)
{
internal static bool IsBaseOfPage(this Uri baseUri, string? uriString)
if (string.IsNullOrWhiteSpace(uriString))
{
if (Path.HasExtension(uriString))
{
// If the path ends in a file extension, it's not referring to a page.
return false;
}
return false;
Comment thread
tw4 marked this conversation as resolved.
}

var uri = new Uri(uriString!);
return baseUri.IsBaseOf(uri);
if (!Uri.TryCreate(uriString, UriKind.Absolute, out var uri))
{
return false;
}

if (Path.HasExtension(uri.GetComponents(UriComponents.Path, UriFormat.Unescaped)))
{
return false;
}

return baseUri.IsBaseOf(uri);
}
}
3 changes: 3 additions & 0 deletions src/BlazorWebView/src/Maui/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Internals;
using System.Runtime.CompilerServices;


[assembly: Preserve]

[assembly: XmlnsDefinition("http://schemas.microsoft.com/dotnet/2021/maui", "Microsoft.AspNetCore.Components.WebView.Maui")]
[assembly: InternalsVisibleTo("Microsoft.Maui.MauiBlazorWebView.UnitTests")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>$(_MauiDotNetTfm)</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>Microsoft.Maui.MauiBlazorWebView.UnitTests</RootNamespace>
<AssemblyName>Microsoft.Maui.MauiBlazorWebView.UnitTests</AssemblyName>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ The new BlazorWebView unit tests are added as a project/solution entry, but they are not wired into the repo's unit-test execution lists. eng/cake/dotnet.cake only enumerates specific patterns for dotnet-test and does not include **/MauiBlazorWebView.UnitTests.csproj; eng/helix.proj likewise lists each XUnitProject explicitly and omits this project. As a result, the regression tests for IsBaseOfPage can build in the solution but not run in the normal unit-test/Helix paths, so CI would not catch this bug regressing. Please add this project to the relevant unit-test runner lists.

</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="$(CoverletCollectorPackageVersion)" />
<PackageReference Include="xunit" Version="$(XunitPackageVersion)" />
</ItemGroup>

<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Maui\Microsoft.AspNetCore.Components.WebView.Maui.csproj" />
</ItemGroup>


</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
using Microsoft.AspNetCore.Components.WebView.Maui;

namespace Microsoft.Maui.MauiBlazorWebView.UnitTests;

public class UriExtensions_Tests
{
private readonly Uri _baseUri = new("https://example.com/");

[Theory]
[InlineData("https://example.com/page", true)]
[InlineData("page/subpage", false)]
[InlineData("this is not a uri!", false)]
[InlineData("https://example.com/", true)]
[InlineData("https://example.com/page/", true)]
[InlineData("https://example.com/page?weight=62.5", true)]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[moderate] Regression Prevention — The regression case exercises https://example.com/..., but the failing BlazorWebView paths use platform app origins (https://0.0.0.1/... on Android and app://0.0.0.1/... on iOS/MacCatalyst). Add query-dot/fragment-dot cases for those actual origins so the test reproduces the platform scenarios this helper is used for, rather than only a generic HTTPS host.

[InlineData("https://example.com/page#section.1", true)]
[InlineData("https://example.com/file.txt", false)]
[InlineData("https://example.com/page.json?foo=bar", false)]
[InlineData("ftp://example.com/page", false)]
[InlineData("/relative/path", false)]
[InlineData("", false)]
[InlineData(null, false)]
[InlineData("https://example.com/test", true)]
[InlineData("https://example.com/folder/subfolder/", true)]
[InlineData("https://example.com/folder/file.exe", false)]
[InlineData("https://subdomain.example.com/page", false)]
[InlineData("https://example.com/path/with/.dot/segment", true)]
[InlineData("https://example.com/path/with space", true)]
[InlineData("https://example.com/path/with%20encoded%20space", true)]
[InlineData("https://example.com/page?param=value&param2=value2", true)]
[InlineData("https://example.com/page.html", false)]
[InlineData("HTTPS://EXAMPLE.COM/PAGE", true)]
[InlineData("https://subdomain.example.com/", false)]
[InlineData("https://subdomain.example.com/page/", false)]
[InlineData("https://subdomain.example.com/page?weight=62.5", false)]
[InlineData("https://subdomain.example.com/page#section.1", false)]
[InlineData("https://subdomain.example.com/file.txt", false)]
[InlineData("https://subdomain.example.com/page.json?foo=bar", false)]
[InlineData("ftp://subdomain.example.com/page", false)]
[InlineData("https://subdomain.example.com/test", false)]
[InlineData("https://subdomain.example.com/folder/subfolder/", false)]
[InlineData("https://subdomain.example.com/folder/file.exe", false)]
[InlineData("https://subdomain.example.com/path/with/.dot/segment", false)]
[InlineData("https://subdomain.example.com/path/with space", false)]
[InlineData("https://subdomain.example.com/path/with%20encoded%20space", false)]
[InlineData("https://subdomain.example.com/page?param=value&param2=value2", false)]
[InlineData("https://subdomain.example.com/page.html", false)]
[InlineData("HTTPS://SUBDOMAIN.EXAMPLE.COM/PAGE", false)]
public void IsBaseOfPage_HandlesVariousUris(string? uriString, bool expected)
Comment thread
tw4 marked this conversation as resolved.
{
var result = _baseUri.IsBaseOfPage(uriString);
Assert.Equal(expected, result);
}

[Fact]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor] Regression Prevention — Test duplication — Five of the six standalone [Fact] methods in this block duplicate [InlineData] cases that already exist in IsBaseOfPage_HandlesVariousUris above:

Fact method Duplicate Theory InlineData
IsBaseOfPage_ReturnsFalse_WhenPathHasFileExtension (line 57) ("https://example.com/file.txt", false) (line 17)
IsBaseOfPage_ReturnsTrue_WhenUriIsBaseItself (line 63) ("https://example.com/", true) (line 13)
IsBaseOfPage_IgnoresDotInQuery_WhenBaseUriMatches (line 70) ("https://example.com/page?weight=62.5", true) (line 15)
IsBaseOfPage_ReturnsFalse_WhenSchemeDiffersFromBase (line 77) ("ftp://example.com/page", false) (line 19)
IsBaseOfPage_TreatsFragmentWithDotAsNoExtension (line 100) ("https://example.com/page#section.1", true) (line 16)

Consider removing these duplicates and consolidating only the non-redundant case (IsBaseOfPage_DoesNotTreatDotInQueryAsExtension) into the Theory, or keep it as a named Fact with an issue-reference comment (see next finding). Duplicate test cases inflate pass counts without adding coverage and make it harder to identify genuine regression tests at a glance.

public void IsBaseOfPage_ReturnsFalse_WhenPathHasFileExtension()
{
var uriWithExtension = "https://example.com/assets/image.png";
Assert.False(_baseUri.IsBaseOfPage(uriWithExtension));
}

[Fact]
public void IsBaseOfPage_ReturnsTrue_WhenUriIsBaseItself()
{
var uri = "https://example.com/";
Assert.True(_baseUri.IsBaseOfPage(uri));
}

[Fact]
public void IsBaseOfPage_IgnoresDotInQuery_WhenBaseUriMatches()
{
var uri = "https://example.com/page?foo=1.2.3";
Assert.True(_baseUri.IsBaseOfPage(uri));
}

[Fact]
public void IsBaseOfPage_ReturnsFalse_WhenSchemeDiffersFromBase()
{
var uri = "ftp://example.com/page";
Assert.False(_baseUri.IsBaseOfPage(uri));
}

[Fact]
public void IsBaseOfPage_DoesNotTreatDotInQueryAsExtension()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor] Regression Prevention — Missing issue reference on primary regression testIsBaseOfPage_DoesNotTreatDotInQueryAsExtension is the most important test in this file: it is the direct reproduction of issue #25689 (?weight=62.5 being incorrectly identified as a file extension). Add a comment linking it to the issue so reviewers and future maintainers can trace it back to its origin:

// Regression test for https://github.com/dotnet/maui/issues/25689
// A URL with a dot in the query parameter (e.g. ?weight=62.5) must not be
// treated as a file-extension path and must be allowed to fall back to the host page.
[Fact]
public void IsBaseOfPage_DoesNotTreatDotInQueryAsExtension()

Without this comment, the test is indistinguishable from the duplicate facts above and its specific regression value is invisible.

{
var baseUri = new Uri("https://example.com");
var urlWithDotInQuery = "https://example.com/customer?weight=62.5";
Assert.True(baseUri.IsBaseOfPage(urlWithDotInQuery));
}

[Fact]
public void IsBaseOfPage_ReturnsFalse_WhenPathHasDotExtension()
{
var baseUri = new Uri("https://example.com");
var urlWithExtension = "https://example.com/customer.json";
Assert.False(baseUri.IsBaseOfPage(urlWithExtension));
}

[Fact]
public void IsBaseOfPage_TreatsFragmentWithDotAsNoExtension()
{
var baseUri = new Uri("https://example.com");
var urlWithDotInFragment = "https://example.com/customer#section.1";
Assert.True(baseUri.IsBaseOfPage(urlWithDotInFragment));
}
}
Loading