mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-16 10:33:10 +00:00
Update name censor to check for certain substrings (#3603)
## Description: The deduper was converting profane words like "kkk" => "k" and then censoring all usernames with the letter "k", so instead we just hardcode and check for substrings for profane phrases like that. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: evan
This commit is contained in:
@@ -131,6 +131,13 @@ describe("UsernameCensor", () => {
|
||||
// "snigger" is whitelisted in englishDataset
|
||||
expect(matcher.hasMatch("snigger")).toBe(false);
|
||||
});
|
||||
|
||||
test("catches kkk as substring", () => {
|
||||
expect(matcher.hasMatch("kkk")).toBe(true);
|
||||
expect(matcher.hasMatch("KKK")).toBe(true);
|
||||
expect(matcher.hasMatch("kkklover")).toBe(true);
|
||||
expect(matcher.hasMatch("ilovekkkboys")).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("censorUsername", () => {
|
||||
@@ -186,6 +193,15 @@ describe("UsernameCensor", () => {
|
||||
expect(checker.censorUsername("[NAZI]CoolPlayer")).toBe("CoolPlayer");
|
||||
});
|
||||
|
||||
test("removes [SS] clan tag", () => {
|
||||
expect(checker.censorUsername("[SS]Player")).toBe("Player");
|
||||
expect(checker.censorUsername("[ss]Player")).toBe("Player");
|
||||
});
|
||||
|
||||
test("removes [KKK] clan tag", () => {
|
||||
expect(checker.censorUsername("[KKK]Player")).toBe("Player");
|
||||
});
|
||||
|
||||
test("keeps clean clan tag when username is clean", () => {
|
||||
expect(checker.censorUsername("[COOL]Player")).toBe("[COOL] Player");
|
||||
expect(checker.censorUsername("[PRO]Player")).toBe("[PRO] Player");
|
||||
|
||||
Reference in New Issue
Block a user