Skip to content

Commit

Permalink
Use GeneratedRegex
Browse files Browse the repository at this point in the history
  • Loading branch information
nurhafiz committed May 2, 2024
1 parent 8cb3326 commit 8ced544
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Toimik.UrlNormalization/UrlNormalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ namespace Toimik.UrlNormalization;
/// If <c>true</c>, occurrences of two or more adjacent slashes in a path is collapsed into one. The
/// default is <c>true</c> .
/// </param>
public class UrlNormalizer(bool isAdjacentSlashesCollapsed = true)
public partial class UrlNormalizer(bool isAdjacentSlashesCollapsed = true)
{
private static readonly Regex AdjacentSlashesRegex = new("/{2,}", RegexOptions.Compiled);
private static readonly Regex AdjacentSlashesRegex = AtLeastTwoCharactersRegex();

public bool IsAdjacentSlashesCollapsed { get; } = isAdjacentSlashesCollapsed;

Expand Down Expand Up @@ -188,4 +188,7 @@ protected virtual string NormalizePercentEncoding(string text)
text = builder.ToString();
return text;
}

[GeneratedRegex("/{2,}", RegexOptions.Compiled)]
private static partial Regex AtLeastTwoCharactersRegex();
}

0 comments on commit 8ced544

Please sign in to comment.