Update DfaMatcherBuilder to use the correct behavior (#25616)
This commit is contained in:
parent
2228c98b88
commit
0637599517
|
|
@ -49,7 +49,7 @@ namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UseCorrectCatchAllBehavior = false; // default to bugged behavior
|
UseCorrectCatchAllBehavior = true; // default to correct behavior
|
||||||
}
|
}
|
||||||
|
|
||||||
var (nodeBuilderPolicies, endpointComparerPolicies, endpointSelectorPolicies) = ExtractPolicies(policies.OrderBy(p => p.Order));
|
var (nodeBuilderPolicies, endpointComparerPolicies, endpointSelectorPolicies) = ExtractPolicies(policies.OrderBy(p => p.Order));
|
||||||
|
|
|
||||||
|
|
@ -543,7 +543,7 @@ namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
public void BuildDfaTree_MultipleEndpoint_ParameterAndCatchAll_OnSameNode_Order2_DefaultBehavior()
|
public void BuildDfaTree_MultipleEndpoint_ParameterAndCatchAll_OnSameNode_Order2_DefaultBehavior()
|
||||||
{
|
{
|
||||||
var builder = CreateDfaMatcherBuilder();
|
var builder = CreateDfaMatcherBuilder();
|
||||||
BuildDfaTree_MultipleEndpoint_ParameterAndCatchAll_OnSameNode_Order2_LegacyBehavior_Core(builder);
|
BuildDfaTree_MultipleEndpoint_ParameterAndCatchAll_OnSameNode_Order2_CorrectBehavior_Core(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -636,7 +636,11 @@ namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
// Arrange
|
// Arrange
|
||||||
var builder = CreateDfaMatcherBuilder();
|
var builder = CreateDfaMatcherBuilder();
|
||||||
builder.UseCorrectCatchAllBehavior = true;
|
builder.UseCorrectCatchAllBehavior = true;
|
||||||
|
BuildDfaTree_MultipleEndpoint_CatchAllWithHigherPrecedenceThanParameter_Order1_CorrectBehavior_Core(builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BuildDfaTree_MultipleEndpoint_CatchAllWithHigherPrecedenceThanParameter_Order1_CorrectBehavior_Core(DfaMatcherBuilder builder)
|
||||||
|
{
|
||||||
var endpoint1 = CreateEndpoint("{a}/{b}", order: 0);
|
var endpoint1 = CreateEndpoint("{a}/{b}", order: 0);
|
||||||
builder.AddEndpoint(endpoint1);
|
builder.AddEndpoint(endpoint1);
|
||||||
|
|
||||||
|
|
@ -688,10 +692,14 @@ namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
[Fact]
|
[Fact]
|
||||||
public void BuildDfaTree_MultipleEndpoint_CatchAllWithHigherPrecedenceThanParameter_Order2_CorrectBehavior()
|
public void BuildDfaTree_MultipleEndpoint_CatchAllWithHigherPrecedenceThanParameter_Order2_CorrectBehavior()
|
||||||
{
|
{
|
||||||
// Arrange
|
|
||||||
var builder = CreateDfaMatcherBuilder();
|
var builder = CreateDfaMatcherBuilder();
|
||||||
builder.UseCorrectCatchAllBehavior = true;
|
builder.UseCorrectCatchAllBehavior = true;
|
||||||
|
BuildDfaTree_MultipleEndpoint_CatchAllWithHigherPrecedenceThanParameter_Order2_CorrectBehavior_Core(builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BuildDfaTree_MultipleEndpoint_CatchAllWithHigherPrecedenceThanParameter_Order2_CorrectBehavior_Core(DfaMatcherBuilder builder)
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
var endpoint1 = CreateEndpoint("a/{*b}", order: 0);
|
var endpoint1 = CreateEndpoint("a/{*b}", order: 0);
|
||||||
builder.AddEndpoint(endpoint1);
|
builder.AddEndpoint(endpoint1);
|
||||||
|
|
||||||
|
|
@ -744,7 +752,7 @@ namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
public void BuildDfaTree_MultipleEndpoint_CatchAllWithHigherPrecedenceThanParameter_Order1_DefaultBehavior()
|
public void BuildDfaTree_MultipleEndpoint_CatchAllWithHigherPrecedenceThanParameter_Order1_DefaultBehavior()
|
||||||
{
|
{
|
||||||
var builder = CreateDfaMatcherBuilder();
|
var builder = CreateDfaMatcherBuilder();
|
||||||
BuildDfaTree_MultipleEndpoint_CatchAllWithHigherPrecedenceThanParameter_Order1_Legacy30Behavior_Core(builder);
|
BuildDfaTree_MultipleEndpoint_CatchAllWithHigherPrecedenceThanParameter_Order1_CorrectBehavior_Core(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regression test for https://github.com/dotnet/aspnetcore/issues/18677
|
// Regression test for https://github.com/dotnet/aspnetcore/issues/18677
|
||||||
|
|
@ -803,7 +811,7 @@ namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
public void BuildDfaTree_MultipleEndpoint_CatchAllWithHigherPrecedenceThanParameter_Order2_DefaultBehavior()
|
public void BuildDfaTree_MultipleEndpoint_CatchAllWithHigherPrecedenceThanParameter_Order2_DefaultBehavior()
|
||||||
{
|
{
|
||||||
var builder = CreateDfaMatcherBuilder();
|
var builder = CreateDfaMatcherBuilder();
|
||||||
BuildDfaTree_MultipleEndpoint_CatchAllWithHigherPrecedenceThanParameter_Order2_Legacy30Behavior_Core(builder);
|
BuildDfaTree_MultipleEndpoint_CatchAllWithHigherPrecedenceThanParameter_Order2_CorrectBehavior_Core(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regression test for https://github.com/dotnet/aspnetcore/issues/18677
|
// Regression test for https://github.com/dotnet/aspnetcore/issues/18677
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,8 @@ namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
//
|
//
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("/middleware", 1)]
|
[InlineData("/middleware", 1)]
|
||||||
[InlineData("/middleware/test", 0)]
|
[InlineData("/middleware/test", 1)]
|
||||||
[InlineData("/middleware/test1/test2", -1)]
|
[InlineData("/middleware/test1/test2", 1)]
|
||||||
[InlineData("/bill/boga", 0)]
|
[InlineData("/bill/boga", 0)]
|
||||||
public async Task Match_Regression_1867_DefaultBehavior(string path, int endpointIndex)
|
public async Task Match_Regression_1867_DefaultBehavior(string path, int endpointIndex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue