Improve url regexp

relates to #5
This commit is contained in:
hzrd149 2023-08-10 15:28:10 -05:00
parent 3156607612
commit 1bc4500215
2 changed files with 6 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
"nostrudel": patch
---
Fix non-english characters breaking links

View File

@ -53,7 +53,7 @@ export type LinkEmbedHandler = (link: URL) => JSX.Element | string | null;
export function embedUrls(content: EmbedableContent, handlers: LinkEmbedHandler[]) {
return embedJSX(content, {
name: "embedUrls",
regexp: /https?:\/\/([\dA-z\.-]+\.[A-z\.]{2,12})(\/[\+~%\/\.\w\-_@]*)?([\?#][^\s]+)?/i,
regexp: /https?:\/\/([a-zA-Z0-9\.\-]+\.[a-zA-Z]+)([\p{Letter}\p{Number}&\.-\/\?=#\-@%\+]*)/iu,
render: (match) => {
try {
const url = new URL(match[0]);