From 8d2f2a6220397f13ba98f0c26ba6dec7e4152647 Mon Sep 17 00:00:00 2001 From: Thomas Stringer Date: Wed, 29 Jun 2022 20:51:14 -0400 Subject: [PATCH] Fix newline for denied This was originally fixed for approved in #12 but the denied case was missing. This adds a failing test and the fix for it. --- approval.go | 2 +- approval_test.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/approval.go b/approval.go index d1bc050..db2dbae 100644 --- a/approval.go +++ b/approval.go @@ -147,7 +147,7 @@ func isApproved(commentBody string) (bool, error) { func isDenied(commentBody string) (bool, error) { for _, deniedWord := range deniedWords { - matched, err := regexp.MatchString(fmt.Sprintf("(?i)^%s[.!]?$", deniedWord), commentBody) + matched, err := regexp.MatchString(fmt.Sprintf("(?i)^%s[.!]*\n*$", deniedWord), commentBody) if err != nil { return false, err } diff --git a/approval_test.go b/approval_test.go index 5d7f219..4ff0c83 100644 --- a/approval_test.go +++ b/approval_test.go @@ -316,6 +316,11 @@ func TestDeniedCommentBody(t *testing.T) { commentBody: "this is just some random comment", isSuccess: false, }, + { + name: "denied_with_newline", + commentBody: "denied\n", + isSuccess: true, + }, } for _, testCase := range testCases {