about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/util
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-08-28 12:40:19 +0200
committerThibG <thib@sitedethib.com>2018-08-28 19:52:28 +0200
commite3246cd13b6ee034f5c8e969828332dc9312d449 (patch)
tree7027e2c853fab81a0bf80cfb35c83da3080cae36 /app/javascript/flavours/glitch/util
parent14563f51674aa601b7684dc62a394469a9634c4d (diff)
Preserve hashtag casing in threaded mode
Inspired by f9b23a5d6247445ea5b70b431c934a4bb99213bc
Diffstat (limited to 'app/javascript/flavours/glitch/util')
-rw-r--r--app/javascript/flavours/glitch/util/hashtag.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/util/hashtag.js b/app/javascript/flavours/glitch/util/hashtag.js
new file mode 100644
index 000000000..d5ea57662
--- /dev/null
+++ b/app/javascript/flavours/glitch/util/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] : tag;
+    }
+  );
+}