fix: Fix agent name in Twitter channel private note acting as a link (#4326)

This commit is contained in:
Sivin Varghese 2022-03-31 20:22:52 +05:30 committed by GitHub
parent eff3a50316
commit 3cd1616df6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 7 deletions

View file

@ -13,8 +13,9 @@ const TWITTER_HASH_REPLACEMENT =
const USER_MENTIONS_REGEX = /mention:\/\/(user|team)\/(\d+)\/(.+)/gm;
class MessageFormatter {
constructor(message, isATweet = false) {
constructor(message, isATweet = false, isAPrivateNote = false) {
this.message = DOMPurify.sanitize(escapeHtml(message || ''));
this.isAPrivateNote = isAPrivateNote;
this.isATweet = isATweet;
this.marked = marked;
@ -35,7 +36,7 @@ class MessageFormatter {
}
formatMessage() {
if (this.isATweet) {
if (this.isATweet && !this.isAPrivateNote) {
const withUserName = this.message.replace(
TWITTER_USERNAME_REGEX,
TWITTER_USERNAME_REPLACEMENT