feat: Better styling on web pages, bad-words check now has less edge cases.
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
import Foundation
|
||||
import Vapor
|
||||
|
||||
func checkForBadWords(in string: String) throws {
|
||||
if badWords.contains(string) {
|
||||
throw BadWordError()
|
||||
} else if string.contains(" ") {
|
||||
let parts = string.split(separator: " ")
|
||||
for part in parts {
|
||||
if badWords.contains(String(part)) {
|
||||
throw BadWordError()
|
||||
}
|
||||
let split = string.split(separator: "\n")
|
||||
for string in split {
|
||||
for word in badWords where string.contains(word) {
|
||||
throw Abort(.badRequest, reason: "Stop using such naughty language.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct BadWordError: Error {}
|
||||
|
||||
let badWords: [String] = [
|
||||
"420",
|
||||
"69",
|
||||
"puppy",
|
||||
"kitty",
|
||||
"2g1c",
|
||||
"a-hole",
|
||||
"a-holes",
|
||||
|
||||
Reference in New Issue
Block a user