diff --git a/lib/shared/account-utils.js b/lib/shared/account-utils.js --- a/lib/shared/account-utils.js +++ b/lib/shared/account-utils.js @@ -16,6 +16,10 @@ `^${oldValidUsernameRegexString}$`, ); +// when bolding @-mentions, we want to match both valid usernames and also +// resolved ENS names that have a . character in them (eg. "foo.eth") +const markdownUserMentionRegexString = '[a-zA-Z0-9-_.]+'; + const validEmailRegex: RegExp = new RegExp( /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+/.source + /@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?/.source + @@ -53,9 +57,9 @@ export { usernameMaxLength, - oldValidUsernameRegexString, validUsernameRegex, oldValidUsernameRegex, + markdownUserMentionRegexString, validEmailRegex, validHexColorRegex, accountHasPassword, diff --git a/lib/shared/mention-utils.js b/lib/shared/mention-utils.js --- a/lib/shared/mention-utils.js +++ b/lib/shared/mention-utils.js @@ -2,7 +2,7 @@ import * as React from 'react'; -import { oldValidUsernameRegexString } from './account-utils.js'; +import { markdownUserMentionRegexString } from './account-utils.js'; import SentencePrefixSearchIndex from './sentence-prefix-search-index.js'; import { threadOtherMembers } from './thread-utils.js'; import { stringForUserExplicit } from './user-utils.js'; @@ -50,7 +50,7 @@ // The simple-markdown package already breaks words out for us, and we are // supposed to only match when the first word of the input matches const markdownUserMentionRegex: RegExp = new RegExp( - `^(@(${oldValidUsernameRegexString}))\\b`, + `^(@(${markdownUserMentionRegexString}))\\b`, ); function isUserMentioned(username: string, text: string): boolean { @@ -58,7 +58,7 @@ } const userMentionsExtractionRegex = new RegExp( - `\\B(@(${oldValidUsernameRegexString}))\\b`, + `\\B(@(${markdownUserMentionRegexString}))\\b`, 'g', );