From 75291dc809c2f5b7e4c7568ad1866e3b58deab5e Mon Sep 17 00:00:00 2001 From: Yuriy Putsan Date: Sun, 21 Feb 2021 12:29:29 +0200 Subject: [PATCH] replace var to const --- index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 3ea3d20..b98a37f 100644 --- a/index.js +++ b/index.js @@ -11,10 +11,10 @@ module.exports = isUrl; * Use two levels of REs to avoid REDOS. */ -var protocolAndDomainRE = /^(?:\w+:)?\/\/(\S+)$/; +const protocolAndDomainRE = /^(?:\w+:)?\/\/(\S+)$/; -var localhostDomainRE = /^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/ -var nonLocalhostDomainRE = /^[^\s\.]+\.\S{2,}$/; +const localhostDomainRE = /^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/ +const nonLocalhostDomainRE = /^[^\s\.]+\.\S{2,}$/; /** * Loosely validate a URL `string`. @@ -28,12 +28,12 @@ function isUrl(string){ return false; } - var match = string.match(protocolAndDomainRE); + const match = string.match(protocolAndDomainRE); if (!match) { return false; } - var everythingAfterProtocol = match[1]; + const everythingAfterProtocol = match[1]; if (!everythingAfterProtocol) { return false; }