23 lines
455 B
Go
23 lines
455 B
Go
package server
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"slices"
|
||
|
|
"strings"
|
||
|
|
)
|
||
|
|
|
||
|
|
var profaneWords = []string{"kerfuffle", "sharbert", "fornax"}
|
||
|
|
|
||
|
|
// cleanProfanity replaces profane words with asterisks, case-insensitively,
|
||
|
|
// matching on whole words only.
|
||
|
|
func cleanProfanity(body string) string {
|
||
|
|
words := strings.Split(body, " ")
|
||
|
|
|
||
|
|
for i, word := range words {
|
||
|
|
if slices.Contains(profaneWords, strings.ToLower(word)) {
|
||
|
|
words[i] = "****"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return strings.Join(words, " ")
|
||
|
|
}
|