From 9d349558366f3e001ce162308dcdc73142129042 Mon Sep 17 00:00:00 2001 From: Reto Brunner Date: Sun, 29 Jan 2023 17:04:41 +0100 Subject: [PATCH] extract cleanIrcMessage from client to shared --- server/plugins/irc-events/message.ts | 2 +- server/tsconfig.json | 1 - shared/irc.ts | 6 ++++++ 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 shared/irc.ts diff --git a/server/plugins/irc-events/message.ts b/server/plugins/irc-events/message.ts index 469ecabb..682d3b8a 100644 --- a/server/plugins/irc-events/message.ts +++ b/server/plugins/irc-events/message.ts @@ -1,6 +1,6 @@ import Msg, {MessageType} from "../../models/msg"; import LinkPrefetch from "./link"; -import cleanIrcMessage from "../../../client/js/helpers/ircmessageparser/cleanIrcMessage"; +import {cleanIrcMessage} from "../../../shared/irc"; import Helper from "../../helper"; import {IrcEventHandler} from "../../client"; import Chan, {ChanType} from "../../models/chan"; diff --git a/server/tsconfig.json b/server/tsconfig.json index 1c012b95..ef6e0817 100644 --- a/server/tsconfig.json +++ b/server/tsconfig.json @@ -2,7 +2,6 @@ "extends": "../tsconfig.base.json" /* Path to base configuration file to inherit from. Requires TypeScript version 2.1 or later. */, "include": [ "**/*", - "../client/js/helpers/ircmessageparser/*.ts", "../shared/" ] /* Specifies a list of glob patterns that match files to be included in compilation. If no 'files' or 'include' property is present in a tsconfig.json, the compiler defaults to including all files in the containing directory and subdirectories except those specified by 'exclude'. Requires TypeScript version 2.0 or later. */, "files": [ diff --git a/shared/irc.ts b/shared/irc.ts new file mode 100644 index 00000000..4a18613e --- /dev/null +++ b/shared/irc.ts @@ -0,0 +1,6 @@ +const matchFormatting = + /\x02|\x1D|\x1F|\x16|\x0F|\x11|\x1E|\x03(?:[0-9]{1,2}(?:,[0-9]{1,2})?)?|\x04(?:[0-9a-f]{6}(?:,[0-9a-f]{6})?)?/gi; + +export function cleanIrcMessage(message: string) { + return message.replace(matchFormatting, "").trim(); +}