From 8187f7f3bd6dc3c6707384a9cf4369c0b27bab4a Mon Sep 17 00:00:00 2001 From: josesimoes Date: Fri, 3 Jan 2025 11:47:23 +0000 Subject: [PATCH] [github-nfbot] More improvements on badly formatted check lists --- github-nfbot/GitHub-nfbot/GitHub_nfbot.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/github-nfbot/GitHub-nfbot/GitHub_nfbot.cs b/github-nfbot/GitHub-nfbot/GitHub_nfbot.cs index e85aeab..0ed24c2 100644 --- a/github-nfbot/GitHub-nfbot/GitHub_nfbot.cs +++ b/github-nfbot/GitHub-nfbot/GitHub_nfbot.cs @@ -1433,11 +1433,17 @@ private static async Task FixCheckListAsync(dynamic payload, ILogger log) var prBodyHash = prBody.GetHashCode(); // fix any typos in check lists - // Define a regex pattern to match any character inside the brackets, including optional spaces - string badCheckBoxesPattern = @"\[\s*[^\s\]]\s*\]"; + // Define a regex pattern to match any character inside the brackets + string badCheckBoxesPattern = @"-?\s*\[\s*([^\s\]]|)\s*\]"; - // Replace all matches with "[x]" - string prBodyFixed = Regex.Replace(prBody, badCheckBoxesPattern, "[x]"); + // Replace all matches with "-[x]" + string prBodyFixed = Regex.Replace(prBody, badCheckBoxesPattern, "- [x]"); + + // now catch all check boxes with more than one space between the brackets + string badCheckBoxesPattern2 = @"-?\s*\[\s{2,}([^\s\]]|)\s{2,}\]"; + + // Replace all matches with "[ ]" + prBodyFixed = Regex.Replace(prBodyFixed, badCheckBoxesPattern2, "- [ ]"); if (prBodyHash != prBodyFixed.GetHashCode()) {