about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/utils/hashtag.js
blob: d91cd5591a33f28d91c57ef21cbc298827fb534e (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);
}