mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-09-19 08:28:55 +00:00
762e4fdf55
This fixes crashes in pleroma when writing toots with a content warning, since pleroma inserts a “nsfw” hashtag that isn't part of the toot's text.
9 lines
302 B
JavaScript
9 lines
302 B
JavaScript
export function recoverHashtags (recognizedTags, text) {
|
|
return recognizedTags.map(tag => {
|
|
const re = new RegExp(`(?:^|[^\/\)\w])#(${tag.name})`, 'i');
|
|
const matched_hashtag = text.match(re);
|
|
return matched_hashtag ? matched_hashtag[1] : null;
|
|
}
|
|
).filter(x => x !== null);
|
|
}
|