From 5a9c4b28fa1d5064e34459ef276b4ef2a0c473f8 Mon Sep 17 00:00:00 2001 From: umaranis Date: Sun, 24 Mar 2024 17:32:44 +1100 Subject: [PATCH] Revert "bug: AutoLink URL recognition failures" New regular expression is complex and slow. This reverts commit c5d07924e725d6d7fa55de39007d2d755b1d1cb8. --- .../src/core/plugins/AutoLink/AutoLinkPlugin.svelte | 2 +- .../src/core/plugins/AutoLink/AutoLinkPluginCore.svelte | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/svelte-lexical/src/core/plugins/AutoLink/AutoLinkPlugin.svelte b/packages/svelte-lexical/src/core/plugins/AutoLink/AutoLinkPlugin.svelte index 1470475a..ffa8042d 100644 --- a/packages/svelte-lexical/src/core/plugins/AutoLink/AutoLinkPlugin.svelte +++ b/packages/svelte-lexical/src/core/plugins/AutoLink/AutoLinkPlugin.svelte @@ -18,7 +18,7 @@ } const URL_REGEX = - /(https?:\/\/)?((\w+:\w+@)?(([a-zA-Z\d]([a-zA-Z\d-]*[a-zA-Z\d])*)\.)+[a-zA-Z]{2,}|localhost|(\d{1,3}\.){3}\d{1,3})(:\d+)?(\/[-a-zA-Z\d%_.~+]*)*(\?[;&a-zA-Z\d%_.~+=-]*)?(#[-a-zA-Z\d_]*)?/; + /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/; const EMAIL_REGEX = /(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/; diff --git a/packages/svelte-lexical/src/core/plugins/AutoLink/AutoLinkPluginCore.svelte b/packages/svelte-lexical/src/core/plugins/AutoLink/AutoLinkPluginCore.svelte index 8bb9b403..68c00731 100644 --- a/packages/svelte-lexical/src/core/plugins/AutoLink/AutoLinkPluginCore.svelte +++ b/packages/svelte-lexical/src/core/plugins/AutoLink/AutoLinkPluginCore.svelte @@ -46,7 +46,7 @@ return null; } - const PUNCTUATION_OR_SPACE = /[,;\s]/; + const PUNCTUATION_OR_SPACE = /[.,;\s]/; function isSeparator(char: string): boolean { return PUNCTUATION_OR_SPACE.test(char);