From 7c122dc72e412e1d376d3c5a37df0c629b83c8d8 Mon Sep 17 00:00:00 2001 From: louis Date: Fri, 20 Oct 2023 22:10:39 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20Remove=20replaceMagic=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Message.tsx | 3 +-- src/lib/helper.ts | 13 ------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/src/components/Message.tsx b/src/components/Message.tsx index e3643a5..e9b5507 100644 --- a/src/components/Message.tsx +++ b/src/components/Message.tsx @@ -4,7 +4,6 @@ import { Message as MessageType } from '../lib/types' import dayjs from 'dayjs' import relativeTime from 'dayjs/plugin/relativeTime' import localizedFormat from 'dayjs/plugin/localizedFormat' -import { replaceMagic } from '../lib/helper' import Attachments from './Attachments' import styled from 'styled-components' import Map from './Map' @@ -34,7 +33,7 @@ const Message: FC = props => {
'), }} /> diff --git a/src/lib/helper.ts b/src/lib/helper.ts index 6752e54..d46a740 100644 --- a/src/lib/helper.ts +++ b/src/lib/helper.ts @@ -6,16 +6,3 @@ export const isMobile = (): boolean => { const width = window.innerWidth || document.documentElement.clientWidth || document.getElementsByTagName('body')[0].clientWidth return width < breakpoints.mobile } - -// FIXME: Might be better to use a library like validator.js -// to catch more cases. -export const replaceMagic = (text: string): string => { - return text - ? text - .replace(/(https?:\/\/([a-zA-Z0-9._\-/]+))/g, '$2') - .replace(/#(\S+)/g, '#$1') - .replace(/ @(\S+)/g, ' @$1') - .replace(/([a-zA-Z0-9_\-.]+@[a-zA-Z0-9_-]+.[a-zA-Z]+)/g, '$1') - .replace(/(?:\r\n|\r|\n)/g, '
') - : '' -}