Skip to content

fix(tags): normalise leading hashes in tag names (#1317) #1351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

Mostafa-Wahied
Copy link
Contributor

@Mostafa-Wahied Mostafa-Wahied commented May 3, 2025

Summary

Fixes #1317 — typing #tag, ##tag, or even ###tag could save a double‑hash tag to the database, breaking search.
We now trim whitespace and strip every leading # on every tag‑creation path:

  • standalone Tags screen (tags.create, tags.update)
  • bookmark editor (bookmarks.updateTags)

UI continues to display #tag; only storage is normalized.

Key changes

packages/trpc/utils/tag.ts: new normalizeTagName helper
packages/trpc/routers/tags.ts: call helper in create and conditional update
packages/trpc/routers/bookmarks.ts: apply helper (bulk) + ignore empty names to avoid values() must be called with at least one value error
packages/trpc/routers/tags.test.ts: +2 tests (create & update) confirming hashes are stripped

Tests

pnpx vitest run packages/trpc

  • All existing suites pass.
  • New cases:
    • ##demo → stored demo (create)
    • rename #foo##bar → stored bar (update)

@Mostafa-Wahied Mostafa-Wahied force-pushed the fix/normalize-tag-leading-hash-1317 branch from 970dde4 to c95d349 Compare May 3, 2025 10:39
@MohamedBassem MohamedBassem merged commit 112aa9d into karakeep-app:main Jun 22, 2025
5 checks passed
@MohamedBassem
Copy link
Collaborator

Thanks for the PR @Mostafa-Wahied and welcome to the contributors list!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent the creation of '##test' hashtag
2 participants