diff --git a/.changeset/clean-drinks-wink.md b/.changeset/clean-drinks-wink.md new file mode 100644 index 000000000..8c0398d8e --- /dev/null +++ b/.changeset/clean-drinks-wink.md @@ -0,0 +1,5 @@ +--- +"nostrudel": minor +--- + +Handle hashtags in search view diff --git a/cypress/e2e/search.cy.ts b/cypress/e2e/search.cy.ts index 6c9f9a60b..7f2025f5f 100644 --- a/cypress/e2e/search.cy.ts +++ b/cypress/e2e/search.cy.ts @@ -56,4 +56,14 @@ describe("Search", () => { }); } }); + + describe("Hashtag", () => { + it("should redirect to hashtag view", () => { + cy.visit("#/search"); + cy.findByRole("searchbox").type("#bitcoin").type("{enter}"); + + cy.url().should("contain", "/t/bitcoin"); + cy.contains("#bitcoin"); + }); + }); }); diff --git a/src/views/search/index.tsx b/src/views/search/index.tsx index 77ea98a19..dcffc807c 100644 --- a/src/views/search/index.tsx +++ b/src/views/search/index.tsx @@ -91,6 +91,8 @@ export default function SearchView() { const handleSearchText = (text: string) => { if (text.startsWith("nostr:") || text.startsWith("web+nostr:") || safeDecode(search)) { navigate({ pathname: "/l/" + encodeURIComponent(text) }, { replace: true }); + } else if (text.trim().match(/^#(\w+)/i)) { + navigate({ pathname: "/t/" + text.toLowerCase().trim().replace(/^#/, "") }); } else { setSearchParams({ q: text }, { replace: true }); }