Skip to content

Commit f37275e

Browse files
nhodgesodilitime
andauthored
fix(client-twitter): clean up mention deduplication (#2185)
Co-authored-by: Odilitime <janesmith@airmail.cc>
1 parent feb9a53 commit f37275e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/client-twitter/src/utils.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -412,19 +412,19 @@ function deduplicateMentions(paragraph: string) {
412412
}
413413

414414
// Extract mentions from the match groups
415-
let mentions = matches.slice(1).filter(Boolean) as string[];
415+
let mentions = matches.slice(0, 1)[0].trim().split(' ')
416416

417417
// Deduplicate mentions
418418
mentions = [...new Set(mentions)];
419419

420420
// Reconstruct the string with deduplicated mentions
421-
const uniqueMentionsString = `@${mentions.join(' ')}`;
421+
const uniqueMentionsString = mentions.join(' ');
422422

423423
// Find where the mentions end in the original string
424424
const endOfMentions = paragraph.indexOf(matches[0]) + matches[0].length;
425425

426426
// Construct the result by combining unique mentions with the rest of the string
427-
return uniqueMentionsString + paragraph.slice(endOfMentions);
427+
return uniqueMentionsString + ' ' + paragraph.slice(endOfMentions);
428428
}
429429

430430
function restoreUrls(
@@ -454,4 +454,4 @@ function splitParagraph(paragraph: string, maxLength: number): string[] {
454454
const restoredChunks = restoreUrls(splittedChunks, placeholderMap);
455455

456456
return restoredChunks;
457-
}
457+
}

0 commit comments

Comments
 (0)