summary refs log tree commit diff homepage
path: root/src/MinecraftHandler.ts
diff options
context:
space:
mode:
authordestruc7i0n <destruc7i0n@users.noreply.github.com>2021-12-29 16:39:46 -0500
committerdestruc7i0n <destruc7i0n@users.noreply.github.com>2021-12-29 16:39:46 -0500
commita04d39a3cbf10e7335889615a36a78827857b566 (patch)
treeab132aeeb0e931e1131c1a46182a9cb5a7e882e5 /src/MinecraftHandler.ts
parentadded config option for watchFile (diff)
downloadshulker-a04d39a3cbf10e7335889615a36a78827857b566.tar.gz
shulker-a04d39a3cbf10e7335889615a36a78827857b566.zip
escape unicode characters
closes #76
Diffstat (limited to 'src/MinecraftHandler.ts')
-rw-r--r--src/MinecraftHandler.ts10
1 files changed, 4 insertions, 6 deletions
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])