]> cat aescling's git repositories - mastodon.git/commitdiff
Fix hashtag processing when sending toots
authorThibaut Girka <thib@sitedethib.com>
Fri, 1 Feb 2019 10:41:34 +0000 (11:41 +0100)
committerThibG <thib@sitedethib.com>
Fri, 1 Feb 2019 11:37:28 +0000 (12:37 +0100)
This fixes crashes in pleroma when writing toots with a content warning,
since pleroma inserts a “nsfw” hashtag that isn't part of the toot's text.

app/javascript/flavours/glitch/util/hashtag.js

index d5ea5766258b34740dc095ddd981977b200a975e..9b663487fe4c74cacfd2c57c874ee53652755fda 100644 (file)
@@ -2,7 +2,7 @@ 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;
+      return matched_hashtag ? matched_hashtag[1] : null;
     }
-  );
+  ).filter(x => x !== null);
 }