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