From 26852d825b1ef39cf57cdda79c86c4adb9276335 Mon Sep 17 00:00:00 2001 From: Sheogorath Date: Tue, 16 Jul 2019 00:26:39 +0200 Subject: [PATCH] Refactor: Abstracted uppercase tokenized command --- src/server.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/server.js b/src/server.js index c160085..ed1e62d 100644 --- a/src/server.js +++ b/src/server.js @@ -28,7 +28,8 @@ server.create = function create() { return net.createServer((socket) => { socket.on('data', function (data) { let tokenized = data.toString("ascii").split("\r\n")[0].split(" ") - switch (tokenized[0].toUpperCase()) { + let command = tokenized[0].toUpperCase() + switch (command) { case "PING": if (tokenized[1] && tokenized[1] === "irc.example.com") { socket.write("PONG irc.example.com\r\n") @@ -62,7 +63,7 @@ server.create = function create() { break; default: - console.error(`Unknown command: ${tokenized[0].toUpperCase()}`); + console.error(`Unknown command: ${command}`); } }).on('error', (err) => { console.error(err);