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;