aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorHenry Wright <henrywright@gmail.com>2018-07-29 23:57:57 +0200
committerHenry Wright <henrywright@gmail.com>2018-07-29 23:57:57 +0200
commitbce848f8a31d59e2cbff42c7cf3fc299f72ca9b2 (patch)
tree53f8edd6153e751c6c9c95bb9fc48eba2c1fa133 /client
parentMerge pull request #18 from OpSimple/master (diff)
downloadhackchat-bce848f8a31d59e2cbff42c7cf3fc299f72ca9b2.tar.gz
hackchat-bce848f8a31d59e2cbff42c7cf3fc299f72ca9b2.zip
Check if the nickname is valid before adding a CSS class
Diffstat (limited to 'client')
-rw-r--r--client/client.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/client/client.js b/client/client.js
index 3adcd0e..1d72c9a 100644
--- a/client/client.js
+++ b/client/client.js
@@ -1,3 +1,4 @@
+const verifyNickname = (nick) => /^[a-zA-Z0-9_]{1,24}$/.test(nick);
var frontpage = [
" _ _ _ _ ",
" | |_ ___ ___| |_ ___| |_ ___| |_ ",
@@ -157,7 +158,7 @@ function pushMessage(args) {
var messageEl = document.createElement('div');
messageEl.classList.add('message');
- if (args.nick == myNick) {
+ if (verifyNickname(myNick) && args.nick == myNick) {
messageEl.classList.add('me');
} else if (args.nick == '!') {
messageEl.classList.add('warn');