Page MenuHomePhorge

D6762.1768810972.diff
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

D6762.1768810972.diff

diff --git a/lib/shared/markdown.js b/lib/shared/markdown.js
--- a/lib/shared/markdown.js
+++ b/lib/shared/markdown.js
@@ -2,7 +2,7 @@
import invariant from 'invariant';
-import { oldValidUsernameRegexString } from './account-utils.js';
+import { markdownMentionRegex } from './mention-utils.js';
import type { RelativeMemberInfo } from '../types/thread-types.js';
// simple-markdown types
@@ -90,8 +90,6 @@
const urlRegex: RegExp = /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/i;
-const mentionRegex = new RegExp(`^(@(${oldValidUsernameRegexString}))\\b`);
-
export type JSONCapture = Array<string> & {
+json: Object,
+index?: void,
@@ -205,18 +203,18 @@
if (!state.inline) {
return null;
}
- const result = mentionRegex.exec(source);
+ const result = markdownMentionRegex.exec(source);
if (!result) {
return null;
}
const username = result[2];
- invariant(username, 'mentionRegex should match two capture groups');
+ invariant(username, 'markdownMentionRegex should match two capture groups');
if (!memberSet.has(username.toLowerCase())) {
return null;
}
return result;
};
- match.regex = mentionRegex;
+ match.regex = markdownMentionRegex;
return match;
}
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
@@ -1,5 +1,6 @@
// @flow
+import { oldValidUsernameRegexString } from './account-utils.js';
import SearchIndex from './search-index.js';
import { threadOtherMembers } from './thread-utils.js';
import { stringForUserExplicit } from './user-utils.js';
@@ -15,6 +16,12 @@
+end: number,
};
+// 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 markdownMentionRegex: RegExp = new RegExp(
+ `^(@(${oldValidUsernameRegexString}))\\b`,
+);
+
function isMentioned(username: string, text: string): boolean {
return new RegExp(`\\B@${username}\\b`, 'i').test(text);
}
@@ -73,6 +80,7 @@
}
export {
+ markdownMentionRegex,
isMentioned,
getTypeaheadUserSuggestions,
getNewTextAndSelection,

File Metadata

Mime Type
text/plain
Expires
Mon, Jan 19, 8:22 AM (18 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5954445
Default Alt Text
D6762.1768810972.diff (2 KB)

Event Timeline