about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/utils/hashtag.js
blob: 8f5665c4665cbcdc3a7abdfbf82780b712784f52 (plain) (blame)
1
2
3
4
5
6
7
8
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);
}