Skip to content

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

fix(workers): AI infered tags can contain " " at the beginning. Fixes #184 (#194)

kamtschatkabe8b91f97cc0
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;