Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3506380
D10388.id34922.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D10388.id34922.diff
View Options
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',
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 4:19 PM (21 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2687718
Default Alt Text
D10388.id34922.diff (1 KB)
Attached To
Mode
D10388: [lib] Modify markdownUserMentionRegex to match ENS names as well
Attached
Detach File
Event Timeline
Log In to Comment