From d79b77ed538851c2435b0bf449ad69ccd39ff014 Mon Sep 17 00:00:00 2001 From: Rory& Date: Thu, 22 May 2025 17:16:38 +0200 Subject: Logging cleanup --- .../Spec/State/Policy/PolicyRuleStateEventContent.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'LibMatrix.EventTypes') 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() { -- cgit 1.5.1