From a04d39a3cbf10e7335889615a36a78827857b566 Mon Sep 17 00:00:00 2001 From: destruc7i0n Date: Wed, 29 Dec 2021 16:39:46 -0500 Subject: escape unicode characters closes #76 --- src/MinecraftHandler.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/MinecraftHandler.ts') diff --git a/src/MinecraftHandler.ts b/src/MinecraftHandler.ts index bddc515..3353994 100644 --- a/src/MinecraftHandler.ts +++ b/src/MinecraftHandler.ts @@ -3,7 +3,9 @@ import path from 'path' import { Tail } from 'tail' import express from 'express' -import { Config } from './Config' +import type { Config } from './Config' + +import { fixMinecraftUsername } from './lib/util' export type LogLine = { username: string @@ -22,10 +24,6 @@ class MinecraftHandler { this.config = config } - private static fixMinecraftUsername (username: string) { - return username.replace(/(ยง[A-Z-a-z0-9])/g, '') - } - private parseLogLine (data: string): LogLine { const ignored = new RegExp(this.config.REGEX_IGNORED_CHAT) @@ -69,7 +67,7 @@ class MinecraftHandler { return null } - const username = MinecraftHandler.fixMinecraftUsername(matches[1]) + const username = fixMinecraftUsername(matches[1]) const message = matches[2] if (this.config.DEBUG) { console.log('[DEBUG] Username: ' + matches[1]) -- cgit 1.4.1