Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Error when sending symbols only in chat #121

Merged
merged 3 commits into from
Apr 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion client/src/shared/state/Chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,18 @@ class Chat {
if (result === undefined) throw new Error(`Server returned an unknown scope: ${scope}`);
}

isAlphaNumericSpace(str) {
return str.match("^[\\w\\s]+$");
}

filterProfanity(message) {
// filter profanity only if it is enabled in the settings
if (this.guiState.profanityFilterEnabled) {
return this.badWords.clean(message);
// check if message contains letters or numbers to avoid error
// https://github.com/web-mech/badwords/issues/103
if (this.isAlphaNumericSpace(message)) {
return this.badWords.clean(message);
}
}

return message;
Expand Down