mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-09-27 12:07:43 +02:00
fix hashtag regexp
This commit is contained in:
@@ -3,6 +3,19 @@ describe("Embeds", () => {
|
|||||||
cy.loginWithNewUser();
|
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", () => {
|
describe("links", () => {
|
||||||
it("embed trustless.computer links", () => {
|
it("embed trustless.computer links", () => {
|
||||||
cy.visit(
|
cy.visit(
|
||||||
|
@@ -67,16 +67,18 @@ export function embedNostrHashtags(content: EmbedableContent, event: NostrEvent
|
|||||||
|
|
||||||
return embedJSX(content, {
|
return embedJSX(content, {
|
||||||
name: "nostr-hashtag",
|
name: "nostr-hashtag",
|
||||||
regexp: /#([^\[\]\s]+)/i,
|
regexp: /#(\w+)/i,
|
||||||
render: (match) => {
|
render: (match) => {
|
||||||
const hashtag = match[1].toLowerCase();
|
const hashtag = match[1].toLowerCase();
|
||||||
|
|
||||||
if (hashtags.includes(hashtag)) {
|
if (hashtags.includes(hashtag)) {
|
||||||
return (
|
return (
|
||||||
<Link as={RouterLink} to={`/t/${hashtag}`} color="blue.500">
|
<Link as={RouterLink} to={`/t/${hashtag}`} color="blue.500">
|
||||||
#{match[1]}
|
#{match[1]}
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
}
|
} else console.log(hashtag, hashtags);
|
||||||
|
|
||||||
return match[0];
|
return match[0];
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user