From cb83df3027dcc60689d7a81123fd97c6b718b617 Mon Sep 17 00:00:00 2001 From: augustlindemer <118665588+augustlindemer@users.noreply.github.com> Date: Fri, 6 Dec 2024 17:17:54 +0000 Subject: [PATCH] fix: correct editor link validation (#4053) --- editor.planx.uk/src/ui/editor/RichTextInput/RichTextInput.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/editor.planx.uk/src/ui/editor/RichTextInput/RichTextInput.tsx b/editor.planx.uk/src/ui/editor/RichTextInput/RichTextInput.tsx index 5b679ea204..a04721cafd 100644 --- a/editor.planx.uk/src/ui/editor/RichTextInput/RichTextInput.tsx +++ b/editor.planx.uk/src/ui/editor/RichTextInput/RichTextInput.tsx @@ -200,8 +200,8 @@ export const emptyContent = "
"; const linkSelectionError = (selectionHtml: string): string | null => { if (selectionHtml.startsWith("") && selectionHtml.endsWith("
")) { const text = selectionHtml.slice(3, -4); - const lowercaseText = text.toLowerCase(); - if (lowercaseText.includes("click") || lowercaseText.includes("here")) { + const lowercaseText = text.toLowerCase().trim().replace(/[.,]/g, ""); + if (lowercaseText === "click here" || lowercaseText === "clicking here") { return "Links must be set over text that accurately describes what the link is for. Avoid generic language such as 'click here'."; } if (text[0] && text[0] !== text[0].toUpperCase() && text.length < 8) {