Skip to content

Commit

Permalink
fix: replace <= with : into regex (#162)
Browse files Browse the repository at this point in the history
* fix: replace <= with : into regex

* fix(lib): replace look behind in regex with a version that supports old Safari

---------

Co-authored-by: Piotr Suwala <[email protected]>
  • Loading branch information
gitmazzio and piotr-suwala authored May 22, 2024
1 parent 0b28eb0 commit 8e20c79
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/src/entities/message-draft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 8e20c79

Please sign in to comment.