From 52b7623c5237a0e1787b2172d8052449e6094b28 Mon Sep 17 00:00:00 2001 From: Rahul Yadav Date: Thu, 5 Sep 2024 00:44:54 +0530 Subject: [PATCH] fix: remove html log message parsing (#100) There is no HTML message, so parsing is not required. --- src/hooks/logActivity.hooks.ts | 3 +-- src/utility/utils.ts | 28 ---------------------------- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/src/hooks/logActivity.hooks.ts b/src/hooks/logActivity.hooks.ts index 893369e..3f4d878 100644 --- a/src/hooks/logActivity.hooks.ts +++ b/src/hooks/logActivity.hooks.ts @@ -1,7 +1,6 @@ import { LogEntry, LogType } from '@/interfaces/log.interface'; import { logState } from '@/state/log.state'; import EventEmitter from '@/utility/eventEmitter'; -import { htmlToAnsi, isHTML } from '@/utility/utils'; import { useRecoilState } from 'recoil'; export function useLogActivity() { @@ -40,7 +39,7 @@ export function useLogActivity() { return; } const logEntry: LogEntry = { - text: isHTML(text.trim()) ? htmlToAnsi(text.trim()) : text, + text, type, timestamp: !disableTimestamp ? new Date().toISOString() : '', }; diff --git a/src/utility/utils.ts b/src/utility/utils.ts index 8cc910c..bd765ef 100644 --- a/src/utility/utils.ts +++ b/src/utility/utils.ts @@ -88,34 +88,6 @@ export const getContractURL = ( }tonviewer.com/${contractAddress}`; }; -export const htmlToAnsi = (html: string) => { - // Replace and tags with ANSI escape codes for bold and italic - html = html.replace(/(.*?)<\/b>/g, '\x1b[1m$1\x1b[22m'); // Bold - html = html.replace(/(.*?)<\/i>/g, '\x1b[3m$1\x1b[23m'); // Italic - - // Replace elements with ANSI escape codes for color - html = html.replace( - /(.*?)<\/span>/g, - (_, color, content) => { - const colorMap: Record = { - red: '\x1b[31m', - green: '\x1b[32m', - yellow: '\x1b[33m', - blue: '\x1b[34m', - reset: '\x1b[0m', - }; - return `${colorMap[color]}${content}${colorMap.reset}`; - }, - ); - - // Remove other HTML tags - html = html.replace(/<\/?[^>]+(>|$)/g, ''); - - return html; -}; - -export const isHTML = RegExp.prototype.test.bind(/(<([^>]+)>)/i); - export const getFileNameFromPath = (filePath: string): string => { const pathArray = filePath.split('/');