From 9ba20f998a12c7af44e4ffd4fd6c167f1efb7685 Mon Sep 17 00:00:00 2001 From: Realfriend's TeamCity Date: Fri, 30 Jun 2023 17:21:24 +0300 Subject: [PATCH] Fix issue with converting db.com > me.com --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 065773c..01ce15a 100644 --- a/index.js +++ b/index.js @@ -44,6 +44,10 @@ class EmailValidation { type === 'blacklist' && result.errors.push(type) } else { let smallestDistance = result.domain.length + const match = /^(.+?)\.([^.]+)$/.exec(result.domain); + if (match) { + smallestDistance = match[1].length; + } for (const domain of popularDomains) { const distance = levenstein(domain, result.domain) if (distance > 0 && distance < maxDistance && distance < smallestDistance) {