mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-04-07 03:18:02 +02:00
handle hashtags in search view
This commit is contained in:
parent
9936c25f8a
commit
644c53ec76
5
.changeset/clean-drinks-wink.md
Normal file
5
.changeset/clean-drinks-wink.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"nostrudel": minor
|
||||
---
|
||||
|
||||
Handle hashtags in search view
|
@ -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");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -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 });
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user