From 5ac4cfcb33f79f5467e1e8a3fb217cf8877abab3 Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Thu, 19 Oct 2023 08:09:09 -0500 Subject: [PATCH] fix hashtags and links with mark char --- .changeset/bright-gifts-nail.md | 5 +++++ src/components/open-graph-card.tsx | 2 +- src/helpers/regexp.ts | 5 ++--- 3 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 .changeset/bright-gifts-nail.md diff --git a/.changeset/bright-gifts-nail.md b/.changeset/bright-gifts-nail.md new file mode 100644 index 000000000..ca809bbd2 --- /dev/null +++ b/.changeset/bright-gifts-nail.md @@ -0,0 +1,5 @@ +--- +"nostrudel": patch +--- + +Fix hashtags and links with mark characters in them diff --git a/src/components/open-graph-card.tsx b/src/components/open-graph-card.tsx index 4ada0cd98..151192446 100644 --- a/src/components/open-graph-card.tsx +++ b/src/components/open-graph-card.tsx @@ -19,7 +19,7 @@ export default function OpenGraphCard({ url, ...props }: { url: URL } & Omit - {url.toString()} + {decodeURI(url.toString())} ); diff --git a/src/helpers/regexp.ts b/src/helpers/regexp.ts index 56bfbb5a8..a7d6bcfa2 100644 --- a/src/helpers/regexp.ts +++ b/src/helpers/regexp.ts @@ -1,8 +1,7 @@ export const getMatchNostrLink = () => /(nostr:|@)?((npub|note|nprofile|nevent|nrelay|naddr)1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{58,})/gi; -export const getMatchHashtag = () => /(^|[^\p{L}])#([\p{L}\p{N}]+)/gu; -export const getMatchLink = () => - /https?:\/\/([a-zA-Z0-9\.\-]+\.[a-zA-Z]+)([\p{Letter}\p{Number}&\.-\/\?=#\-@%\+_,:!]*)/gu; +export const getMatchHashtag = () => /(^|[^\p{L}])#([\p{L}\p{N}\p{M}]+)/gu; +export const getMatchLink = () => /https?:\/\/([a-zA-Z0-9\.\-]+\.[a-zA-Z]+)([\p{L}\p{N}\p{M}&\.-\/\?=#\-@%\+_,:!]*)/gu; export const getMatchEmoji = () => /:([a-zA-Z0-9_-]+):/gi; export const getMatchCashu = () => /cashuA[A-z0-9]+/g;