Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions src/Http/Routing/src/Matching/EndpointComparer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
Expand Down Expand Up @@ -61,7 +61,7 @@ private int ComparePattern(Endpoint x, Endpoint y)
{
if (routeEndpointY != null)
{
return routeEndpointX.RoutePattern.RawText.CompareTo(routeEndpointY.RoutePattern.RawText);
return string.Compare(routeEndpointX.RoutePattern.RawText, routeEndpointY.RoutePattern.RawText, StringComparison.OrdinalIgnoreCase);
}

return 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Collections.Generic;
Expand Down Expand Up @@ -87,7 +87,7 @@ public void Compare_PrefersTemplate_IfOtherCriteriaIsSame()
var result = comparer.Compare(endpoint1, endpoint2);

// Assert
Assert.Equal(1, result);
Assert.True(result > 0);
}

[Fact]
Expand Down Expand Up @@ -218,6 +218,29 @@ public void Sort_MoreSpecific_FirstInList()
e => Assert.Same(endpoint7, e));
}

[Fact]
public void Compare_PatternOrder_OrdinalIgnoreCaseSort()
{
// Arrange
var endpoint1 = CreateEndpoint("/I", order: 0);
var endpoint2 = CreateEndpoint("/i", order: 0);
var endpoint3 = CreateEndpoint("/\u0131", order: 0); // Turkish lowercase i

var list = new List<RouteEndpoint>() { endpoint1, endpoint2, endpoint3 };

var comparer = CreateComparer();

// Act
list.Sort(comparer);

// Assert
Assert.Collection(
list,
e => Assert.Same(endpoint1, e),
e => Assert.Same(endpoint2, e),
e => Assert.Same(endpoint3, e));
}

private static RouteEndpoint CreateEndpoint(string template, int order, params object[] metadata)
{
return new RouteEndpoint(
Expand Down