Skip to content

Commit 8247ae2

Browse files
author
Ivan Palladino
committed
cmd/gopherbot: match just the whole word document
When the title contains the word document then repeat the check with a regex word boundaries rule then return positive just in case of a whole word match. Updates golang/go#31153
1 parent ea2aec8 commit 8247ae2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cmd/gopherbot/gopherbot.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"net/http"
2020
"os"
2121
"path/filepath"
22+
"regexp"
2223
"sort"
2324
"strconv"
2425
"strings"
@@ -1988,8 +1989,11 @@ func isDocumentationTitle(t string) bool {
19881989
if strings.Contains(t, "godoc:") { // in x/tools, or the dozen places people file it as
19891990
return false
19901991
}
1991-
return strings.Contains(t, "documentation") ||
1992-
strings.Contains(t, "docs ")
1992+
if strings.Contains(t, "docs ") {
1993+
return true
1994+
}
1995+
return strings.Contains(t, "document") &&
1996+
regexp.MustCompile(`\bdocument\b`).MatchString(t)
19931997
}
19941998

19951999
func isGoplsTitle(t string) bool {

0 commit comments

Comments
 (0)