diff --git a/cypress/e2e/embeds.cy.ts b/cypress/e2e/embeds.cy.ts index 395f63f86..62e5a36d1 100644 --- a/cypress/e2e/embeds.cy.ts +++ b/cypress/e2e/embeds.cy.ts @@ -3,6 +3,19 @@ describe("Embeds", () => { cy.loginWithNewUser(); }); + describe("hashtags", () => { + it.only('should handle uppercase hashtags and ","', () => { + cy.visit( + "/n/nevent1qqsrj5ns6wva3fcghlyx0hp7hhajqtqk3kuckp7xhhscrm4jl7futegpz9mhxue69uhkummnw3e82efwvdhk6qgswaehxw309ahx7um5wgh8w6twv5pkpt8l" + ); + + cy.findByRole("link", { name: "#Japan" }).should("be.visible"); + cy.findByRole("link", { name: "#kyudo" }).should("be.visible"); + cy.findByRole("link", { name: "#Shiseikan" }).should("be.visible"); + cy.findByRole("link", { name: "#Nostrasia" }).should("be.visible"); + }); + }); + describe("links", () => { it("embed trustless.computer links", () => { cy.visit( diff --git a/src/components/embed-types/nostr.tsx b/src/components/embed-types/nostr.tsx index 3d50684cf..f087eb260 100644 --- a/src/components/embed-types/nostr.tsx +++ b/src/components/embed-types/nostr.tsx @@ -67,16 +67,18 @@ export function embedNostrHashtags(content: EmbedableContent, event: NostrEvent return embedJSX(content, { name: "nostr-hashtag", - regexp: /#([^\[\]\s]+)/i, + regexp: /#(\w+)/i, render: (match) => { const hashtag = match[1].toLowerCase(); + if (hashtags.includes(hashtag)) { return ( #{match[1]} ); - } + } else console.log(hashtag, hashtags); + return match[0]; }, });