fix hashtag regexp

This commit is contained in:
hzrd149
2023-06-05 09:46:42 -04:00
parent f4859bdcc9
commit 28ce0b9c98
2 changed files with 17 additions and 2 deletions

View File

@@ -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(

View File

@@ -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 (
<Link as={RouterLink} to={`/t/${hashtag}`} color="blue.500">
#{match[1]}
</Link>
);
}
} else console.log(hashtag, hashtags);
return match[0];
},
});