glitch-soc/app/javascript/flavours/glitch/utils/hashtag.js
Nick Schonning 7e64eef73b [Glitch] Enable ESLint no-useless-escape
Port db2c58d47a to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
2023-02-18 16:02:12 +01:00

9 lines
293 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);
}