From 762e4fdf557ff7cbdd9fce301060f11bb23cb84e Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Fri, 1 Feb 2019 11:41:34 +0100 Subject: [PATCH] Fix hashtag processing when sending toots MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/javascript/flavours/glitch/util/hashtag.js b/app/javascript/flavours/glitch/util/hashtag.js index d5ea576625..9b663487fe 100644 --- a/app/javascript/flavours/glitch/util/hashtag.js +++ b/app/javascript/flavours/glitch/util/hashtag.js @@ -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); }