From fa462fc65213a60538f3eb94d22c7854ff729158 Mon Sep 17 00:00:00 2001 From: Matteo Mazziotti Date: Mon, 13 May 2024 12:24:24 +0200 Subject: [PATCH 1/2] fix: replace <= with : into regex --- lib/src/entities/message-draft.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/entities/message-draft.ts b/lib/src/entities/message-draft.ts index 2c8c4fb..933713d 100644 --- a/lib/src/entities/message-draft.ts +++ b/lib/src/entities/message-draft.ts @@ -313,8 +313,8 @@ export class MessageDraft { const regex = splitSymbol === "@" - ? /(?<=^|\s)@[^@\s]+(?:\s+[^@\s]+)*/g - : /(?<=^|\s)#[^#\s]+(?:\s+[^#\s]+)*/g + ? /(?:^|\s)@[^@\s]+(?:\s+[^@\s]+)*/g + : /(?:^|\s)#[^#\s]+(?:\s+[^#\s]+)*/g const splitMentionsByAt = (this.value.match(regex) || []).map((splitMention) => splitMention.substring(1) From 9c4673ec7ff7b8cf69d06a3921dfdd4cd6c163a6 Mon Sep 17 00:00:00 2001 From: Piotr Suwala Date: Thu, 16 May 2024 15:46:54 +0800 Subject: [PATCH 2/2] fix(lib): replace look behind in regex with a version that supports old Safari --- lib/src/entities/message-draft.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/src/entities/message-draft.ts b/lib/src/entities/message-draft.ts index 933713d..dc3b673 100644 --- a/lib/src/entities/message-draft.ts +++ b/lib/src/entities/message-draft.ts @@ -311,13 +311,13 @@ export class MessageDraft { delete copiedObject[Number(key)] } - const regex = + const splitSymbolRegex = splitSymbol === "@" - ? /(?:^|\s)@[^@\s]+(?:\s+[^@\s]+)*/g - : /(?:^|\s)#[^#\s]+(?:\s+[^#\s]+)*/g + ? /(^|\s)@([^\s@]+(?:\s+[^\s@]+)*)/g + : /(^|\s)#([^\s#]+(?:\s+[^\s#]+)*)/g - const splitMentionsByAt = (this.value.match(regex) || []).map((splitMention) => - splitMention.substring(1) + const splitMentionsByAt = (this.value.match(splitSymbolRegex) || []).map((match) => + match.trim().substring(1) ) if (referencedName && !splitMentionsByAt[Number(key)]?.startsWith(referencedName)) {