From d4dcf03ad8d10f097d3eca496f6f3af33f1adb85 Mon Sep 17 00:00:00 2001 From: Vishal Gajera Date: Mon, 21 Oct 2024 21:40:00 +0530 Subject: [PATCH] [883] fix: email with query params not get saved in link --- src/controls/Link/index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/controls/Link/index.js b/src/controls/Link/index.js index 71d0cb140..7e2f5c655 100644 --- a/src/controls/Link/index.js +++ b/src/controls/Link/index.js @@ -11,6 +11,21 @@ import linkifyIt from 'linkify-it'; import LayoutComponent from './Component'; const linkify = linkifyIt(); + +linkify.add("mailto:", { + validate: (text, pos) => { + const tail = text.slice(pos - 7); + const mailtoRegex = + /^mailto:[\w.%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(?:\?((subject=[\w\s%+-]*)?&?(body=[\w\s%+-]*)?)?)?$/; + const match = tail.match(mailtoRegex); + if (match) { + return match[0].length; + } + return 0; + }, +}); + + const linkifyLink = params => { const links = linkify.match(params.target); return {