From 31ae7fc800186da8c46ec279bf8753c8664fd915 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Wed, 27 Mar 2019 09:20:19 -0400 Subject: [PATCH] Make sure hashtag checkers work with arrays and not nulls (closes #6116) This is breakage related to #6087 in replacing _.uniqBy with a Set The lodash functions are much more tolerant of nulls and dodgy inputs. --- modules/ui/commit.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/ui/commit.js b/modules/ui/commit.js index c3a042e41..c868cb524 100644 --- a/modules/ui/commit.js +++ b/modules/ui/commit.js @@ -385,7 +385,7 @@ export function uiCommit(context) { if (inComment !== null) { // when hashtags are detected in comment... context.storage('hashtags', null); // always remove stored hashtags - #4304 - if (commentOnly) { inHashTags = null; } // optionally override hashtags field + if (commentOnly) { inHashTags = []; } // optionally override hashtags field } // keep only one copy of the tags @@ -406,21 +406,24 @@ export function uiCommit(context) { // Extract hashtags from `comment` function commentTags() { - return tags.comment + var matches = (tags.comment || '') .replace(/http\S*/g, '') // drop anything that looks like a URL - #4289 .match(hashtagRegex); + + return (matches || []); } // Extract and clean hashtags from `hashtags` function hashTags() { - var t = tags.hashtags || ''; - return t + var matches = (tags.hashtags || '') .split(/[,;\s]+/) .map(function (s) { if (s[0] !== '#') { s = '#' + s; } // prepend '#' var matched = s.match(hashtagRegex); return matched && matched[0]; - }).filter(Boolean); // exclude falsey + }).filter(Boolean); // exclude falsy + + return (matches || []); } }