about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/utils/hashtag.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/javascript/flavours/glitch/utils/hashtag.js')
-rw-r--r--app/javascript/flavours/glitch/utils/hashtag.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/utils/hashtag.js b/app/javascript/flavours/glitch/utils/hashtag.js
new file mode 100644
index 000000000..d91cd5591
--- /dev/null
+++ b/app/javascript/flavours/glitch/utils/hashtag.js
@@ -0,0 +1,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);
+}