From e27cc4235ee97bcc6a6cbb0f50ebb9532b4dd6b9 Mon Sep 17 00:00:00 2001 From: Slava Bezgachev Date: Fri, 19 Oct 2018 09:40:02 +0600 Subject: [PATCH] Altered the validation functions a little for clarity Signed-off-by: Slava Bezgachev --- src/validate.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/validate.js b/src/validate.js index 57597c2..3f7765f 100644 --- a/src/validate.js +++ b/src/validate.js @@ -15,7 +15,7 @@ export function isValidHostname(hostname) { const segments = hostname.split("."); // If at least one segment is empty or longer than 63 chars - sets to true, if none - false const hasLongOrEmptySegments = segments.some( - segment => !segment || segment.length > 63 + segment => segment.length < 1 || segment.length > 63 ); if (hasLongOrEmptySegments) return false; // Must not be all numbers and periods @@ -33,9 +33,6 @@ export function isValidDomain(domain) { const split = domain.split("."); // Has to have at least 2 segments, of at least 1 character each if (split.length < 2) return false; - // If at least one segment is empty - sets to true, if none - false - const hasEmptySegments = split.some(segment => segment.length < 1); - if (hasEmptySegments) return false; return isValidHostname(domain); }