From 3ba96028f41ac8e9428e9881d78c6829d55ee85b Mon Sep 17 00:00:00 2001 From: jahooma Date: Sun, 2 Jan 2022 16:53:20 -0600 Subject: [PATCH] Parse tags to get unique ignoring case --- web/lib/util/parse.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/web/lib/util/parse.ts b/web/lib/util/parse.ts index 2857b7a1..4b20778f 100644 --- a/web/lib/util/parse.ts +++ b/web/lib/util/parse.ts @@ -1,8 +1,9 @@ +import _ from 'lodash' + export function parseTags(text: string) { const regex = /(?:^|\s)(?:[#][a-z0-9_]+)/gi - const matches = text.match(regex) || [] - return matches.map((match) => { - const tag = match.trim().substring(1) - return tag - }) + const matches = (text.match(regex) || []).map((match) => + match.trim().substring(1) + ) + return _.uniqBy(matches, (tag) => tag.toLowerCase()) }