From 08ba133b82eba18a62e8b68c64dfece77d70080d Mon Sep 17 00:00:00 2001 From: kamtschatka Date: Tue, 4 Jun 2024 22:20:52 +0200 Subject: [PATCH] AI infered tags can contain " " at the beginning #184 added a trim to tags to prevent whitespaces at the beginning/end of tags --- apps/workers/openaiWorker.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/workers/openaiWorker.ts b/apps/workers/openaiWorker.ts index 697c9c53..7b74e4c3 100644 --- a/apps/workers/openaiWorker.ts +++ b/apps/workers/openaiWorker.ts @@ -257,11 +257,13 @@ async function inferTags( ); // Sometimes the tags contain the hashtag symbol, let's strip them out if they do. + // Additionally, trim the tags to prevent whitespaces at the beginning/the end of the tag. tags = tags.map((t) => { - if (t.startsWith("#")) { - return t.slice(1); + let tag = t; + if (tag.startsWith("#")) { + tag = t.slice(1); } - return t; + return tag.trim(); }); return tags;