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:
parent
6b85d8fb55
commit
8d2f2a6220
2 changed files with 6 additions and 1 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue