about summary refs log tree commit diff
path: root/LibMatrix.EventTypes
diff options
context:
space:
mode:
Diffstat (limited to 'LibMatrix.EventTypes')
-rw-r--r--LibMatrix.EventTypes/Spec/State/Policy/PolicyRuleStateEventContent.cs12
1 files changed, 5 insertions, 7 deletions
diff --git a/LibMatrix.EventTypes/Spec/State/Policy/PolicyRuleStateEventContent.cs b/LibMatrix.EventTypes/Spec/State/Policy/PolicyRuleStateEventContent.cs

index 6f8c194..949e733 100644 --- a/LibMatrix.EventTypes/Spec/State/Policy/PolicyRuleStateEventContent.cs +++ b/LibMatrix.EventTypes/Spec/State/Policy/PolicyRuleStateEventContent.cs
@@ -98,18 +98,16 @@ public abstract class PolicyRuleEventContent : EventContent { public Regex? GetEntityRegex() => Entity is null ? null : new(Entity.Replace(".", "\\.").Replace("*", ".*").Replace("?", ".")); public bool IsGlobRule() => - Entity != null + !string.IsNullOrWhiteSpace(Entity) && (Entity.Contains('*') || Entity.Contains('?')); public bool EntityMatches(string entity) => - Entity != null + !string.IsNullOrWhiteSpace(entity) + && !string.IsNullOrWhiteSpace(Entity) && ( + // Check if entity is equal regardless of glob check Entity == entity - || ( - IsGlobRule() - ? GetEntityRegex()!.IsMatch(entity) - : entity == Entity - ) + || (IsGlobRule() && GetEntityRegex()!.IsMatch(entity)) ); public string? GetNormalizedRecommendation() {