Skip to content

Commit

Permalink
Allow match condition names to include 0-9 if not the first char
Browse files Browse the repository at this point in the history
  • Loading branch information
lilith committed Jun 12, 2024
1 parent a7efb1a commit c5f0b72
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Imazen.Routing/Matching/ExpressionParsingHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,20 @@ internal static bool TryReadConditionName(ReadOnlySpan<char> text,
for (var i = 0; i < conditionNameEnds; i++)
{
var c = text[i];
if (c != '_' && c != '-' && c is < 'a' or > 'z')
if (i == 0)
{
error = $"Invalid character '{text[i]}' (a-z-_ only) in condition name. Condition expression: '{text.ToString()}'";
return false;
if (c is >= 'a' and <= 'z')
{
continue;
}
} else if (c is >= 'a' and <= 'z' or >= '0' and <= '9' or '_' or '-')
{
continue;
}

error = $"Invalid character '{text[i]}' (a-z)(a-z0-9-_ only) in condition name. Condition expression: '{text.ToString()}'";
return false;

}
error = null;
return true;
Expand Down

0 comments on commit c5f0b72

Please sign in to comment.