about summary refs log tree commit diff
path: root/LibMatrix.EventTypes
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-05-22 17:16:38 +0200
committerRory& <root@rory.gay>2025-05-22 17:17:08 +0200
commitd79b77ed538851c2435b0bf449ad69ccd39ff014 (patch)
treef39a940779547283a4eb934060fbd4650b48c5cf /LibMatrix.EventTypes
parentVarious bug fixes (diff)
downloadLibMatrix-d79b77ed538851c2435b0bf449ad69ccd39ff014.tar.xz
Logging cleanup
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() {