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.
This commit is contained in:
Thomas Stringer 2022-06-29 20:51:14 -04:00
parent 6b85d8fb55
commit 8d2f2a6220
2 changed files with 6 additions and 1 deletions

View file

@ -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
}

View file

@ -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 {