feat: Better styling on web pages, bad-words check now has less edge cases.

This commit is contained in:
2024-12-31 23:57:47 -05:00
parent 8dba393267
commit 26191a15c1
6 changed files with 160 additions and 91 deletions

View File

@@ -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",