mastodon/app/javascript/flavours/glitch/util/hashtag.js

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);
}