mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-09-26 11:37:40 +02:00
fix hashtag regexp
This commit is contained in:
@@ -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(
|
||||
|
@@ -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];
|
||||
},
|
||||
});
|
||||
|
Reference in New Issue
Block a user