From 4bfc9a1fff84ccfb3658757ad2dbd34924af1ced Mon Sep 17 00:00:00 2001 From: codytseng Date: Fri, 5 Sep 2025 10:21:42 +0800 Subject: [PATCH] fix: update URL regex patterns to improve URL matching --- src/constants.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index 768f7eb..725c428 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -96,9 +96,9 @@ export const SUPPORTED_KINDS = [ ] export const URL_REGEX = - /https?:\/\/[\w\p{L}\p{N}\p{M}&.-/?=#\-@%+_:!~*]+(?=[^.,;:'")\]}!?,。;:"'!?】)]|$)/gu + /https?:\/\/[\w\p{L}\p{N}\p{M}&.\-/?=#@%+_:!~*]+[^\s.,;:'")\]}!?,。;:"'!?】)]/gu export const WS_URL_REGEX = - /wss?:\/\/[\w\p{L}\p{N}\p{M}&.-/?=#\-@%+_:!~*]+(?=[^.,;:'")\]}!?,。;:"'!?】)]|$)/gu + /wss?:\/\/[\w\p{L}\p{N}\p{M}&.\-/?=#@%+_:!~*]+[^\s.,;:'")\]}!?,。;:"'!?】)]/gu export const EMAIL_REGEX = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/ export const EMOJI_SHORT_CODE_REGEX = /:[a-zA-Z0-9_-]+:/g export const EMBEDDED_EVENT_REGEX = /nostr:(note1[a-z0-9]{58}|nevent1[a-z0-9]+|naddr1[a-z0-9]+)/g