From 112aa9d942ef0f8548c3728e6218c27cc335a601 Mon Sep 17 00:00:00 2001 From: Mostafa Wahied <97263286+Mostafa-Wahied@users.noreply.github.com> Date: Sun, 22 Jun 2025 11:47:51 -0700 Subject: fix(tags): normalise leading hashes in tag names (#1317) (#1351) * fix(tags): normalise leading hashes in tag names (#1317) * move the transformation to zod * fix openapi spec --------- Co-authored-by: Mohamed Bassem --- packages/trpc/routers/bookmarks.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'packages/trpc/routers/bookmarks.ts') diff --git a/packages/trpc/routers/bookmarks.ts b/packages/trpc/routers/bookmarks.ts index 815cf90d..2a02a0cd 100644 --- a/packages/trpc/routers/bookmarks.ts +++ b/packages/trpc/routers/bookmarks.ts @@ -50,6 +50,7 @@ import { zSearchBookmarksRequestSchema, zUpdateBookmarksRequestSchema, } from "@karakeep/shared/types/bookmarks"; +import { normalizeTagName } from "@karakeep/shared/utils/tag"; import type { AuthedContext, Context } from "../index"; import { authedProcedure, router } from "../index"; @@ -867,9 +868,11 @@ export const bookmarksAppRouter = router({ }; } - const toAddTagNames = input.attach.flatMap((i) => - i.tagName ? [i.tagName] : [], - ); + const toAddTagNames = input.attach + .flatMap((i) => (i.tagName ? [i.tagName] : [])) + .map(normalizeTagName) // strip leading # + .filter((n) => n.length > 0); // drop empty results + const toAddTagIds = input.attach.flatMap((i) => i.tagId ? [i.tagId] : [], ); -- cgit v1.2.3-70-g09d2