Skip to content

fix: displayName mentions#513

Closed
lukashoracek wants to merge 1 commit into
SevenTV:masterfrom
lukashoracek:multi-lang-mentions
Closed

fix: displayName mentions#513
lukashoracek wants to merge 1 commit into
SevenTV:masterfrom
lukashoracek:multi-lang-mentions

Conversation

@lukashoracek
Copy link
Copy Markdown
Contributor

This adds/fixes support for mentions using the displayName rather than the user's international username

JavaScript RegExp does not support unicode \b or (*UCP) so I had to use this ugly workaround, which is used only if the user has different display name than username. I am not sure if there is any better solution than this. Lookbehind support should be fine considering 7TV does not have a Safari extension
I also changed the mention regex to @\S* otherwise unicode mentions are not matched

Fixes #471

@lukashoracek lukashoracek force-pushed the multi-lang-mentions branch 3 times, most recently from c9ef64b to 90beaca Compare April 15, 2023 10:53
@lukashoracek lukashoracek marked this pull request as ready for review April 15, 2023 11:29
@lukashoracek lukashoracek force-pushed the multi-lang-mentions branch 2 times, most recently from 88eeea7 to 6b91a95 Compare April 15, 2023 15:32
Comment on lines +470 to +475
// Workaround \b not working properly with unicode characters
const hasMultiLangName = "displayName" in identity && identity.username !== identity.displayName.toLowerCase();
const rxs = hasMultiLangName
? `((?<=^|\\P{L})${identity.username}|${identity.displayName}(?=\\P{L}|$))`
: `\\b${identity.username}\\b`;
const rx = new RegExp(rxs, hasMultiLangName ? "iu" : "i");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a little overengineered

@AnatoleAM AnatoleAM closed this Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] [Twitch] International name @ mention event doesn't trigger

2 participants