Skip to content

Commit

Permalink
Added StringComparer and forced lowercase where needed to ensure matc…
Browse files Browse the repository at this point in the history
…hing paths to ignore casing. (#8743)
  • Loading branch information
AndreaPiovanelli authored Jan 19, 2024
1 parent e013e00 commit d943fbd
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public void RemoveAliases(AutoroutePart part) {
}

public string GenerateUniqueSlug(AutoroutePart part, IEnumerable<string> existingPaths) {
if (existingPaths == null || !existingPaths.Contains(part.Path))
if (existingPaths == null || !existingPaths.Contains(part.Path, StringComparer.OrdinalIgnoreCase))
return part.Path;

var version = existingPaths.Select(s => GetSlugVersion(part.Path, s)).OrderBy(i => i).LastOrDefault();
Expand Down Expand Up @@ -287,7 +287,8 @@ private string GetDefaultPatternIndex(string contentType, string culture) {

private static int? GetSlugVersion(string path, string potentialConflictingPath) {
int v;
var slugParts = potentialConflictingPath.Split(new[] { path }, StringSplitOptions.RemoveEmptyEntries);
// Matching needs to ignore case, so both paths are forced to lowercase.
var slugParts = potentialConflictingPath.ToLower().Split(new[] { path.ToLower() }, StringSplitOptions.RemoveEmptyEntries);

if (slugParts.Length == 0)
return 2;
Expand Down

0 comments on commit d943fbd

Please sign in to comment.