diff options
| author | Mostafa Wahied <97263286+Mostafa-Wahied@users.noreply.github.com> | 2025-06-22 11:47:51 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-22 19:47:51 +0100 |
| commit | 112aa9d942ef0f8548c3728e6218c27cc335a601 (patch) | |
| tree | 9b0c545fb5b16604e9061e59ebd3d57d7033b4a7 /packages/trpc/routers/bookmarks.ts | |
| parent | c70d64d4cde2bf2acc5c4164eef79c40fd58aa42 (diff) | |
| download | karakeep-112aa9d942ef0f8548c3728e6218c27cc335a601.tar.zst | |
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 <me@mbassem.com>
Diffstat (limited to 'packages/trpc/routers/bookmarks.ts')
| -rw-r--r-- | packages/trpc/routers/bookmarks.ts | 9 |
1 files changed, 6 insertions, 3 deletions
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] : [], ); |
