Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2020-02-18 20:14:50 +0300
committerJames M Snell <jasnell@gmail.com>2020-03-05 22:52:53 +0300
commitb023d61716ddc9cd97cc148bb8d237ec8d894d2b (patch)
treeb4bd2099b7f4142b10019798d3a8e70c0d8abe21 /lib/internal/dns
parent9ec87815027ddf6782ab930975b86333a61ed554 (diff)
lib: move isLegalPort to validators, refactor
isLegalPort was used multiple places in the same way -- to validate the port and throw if necessary. Moved into internal/validators. PR-URL: https://github.com/nodejs/node/pull/31851 Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Diffstat (limited to 'lib/internal/dns')
-rw-r--r--lib/internal/dns/promises.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/internal/dns/promises.js b/lib/internal/dns/promises.js
index ae007fd3193..6ade8854964 100644
--- a/lib/internal/dns/promises.js
+++ b/lib/internal/dns/promises.js
@@ -14,7 +14,7 @@ const {
} = require('internal/dns/utils');
const { codes, dnsException } = require('internal/errors');
const { toASCII } = require('internal/idna');
-const { isIP, isLegalPort } = require('internal/net');
+const { isIP } = require('internal/net');
const {
getaddrinfo,
getnameinfo,
@@ -27,10 +27,11 @@ const {
ERR_INVALID_ARG_TYPE,
ERR_INVALID_OPT_VALUE,
ERR_MISSING_ARGS,
- ERR_SOCKET_BAD_PORT
} = codes;
-const { validateString } = require('internal/validators');
-
+const {
+ validatePort,
+ validateString
+} = require('internal/validators');
function onlookup(err, addresses) {
if (err) {
@@ -162,8 +163,7 @@ function lookupService(address, port) {
if (isIP(address) === 0)
throw new ERR_INVALID_OPT_VALUE('address', address);
- if (!isLegalPort(port))
- throw new ERR_SOCKET_BAD_PORT(port);
+ validatePort(port);
return createLookupServicePromise(address, +port);
}