diff options
author | ZYSzys <17367077526@163.com> | 2018-12-11 18:24:22 +0300 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2018-12-14 04:22:43 +0300 |
commit | a35bd62ae17f9f673430dd90a57ef9bf9f42012a (patch) | |
tree | 0d259d81ed2044ba14cd02a688e3c3f2b9e7b3b9 /lib/internal/dns | |
parent | e9892698655af635f665b7250277fa4c68321313 (diff) |
lib: refactor argument validation using validateString
PR-URL: https://github.com/nodejs/node/pull/24960
Refs: https://github.com/nodejs/node/pull/22101
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'lib/internal/dns')
-rw-r--r-- | lib/internal/dns/promises.js | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/internal/dns/promises.js b/lib/internal/dns/promises.js index 4bf5ac02198..be49ebf2106 100644 --- a/lib/internal/dns/promises.js +++ b/lib/internal/dns/promises.js @@ -21,6 +21,7 @@ const { ERR_MISSING_ARGS, ERR_SOCKET_BAD_PORT } = codes; +const { validateString } = require('internal/validators'); function onlookup(err, addresses) { @@ -192,9 +193,7 @@ function createResolverPromise(resolver, bindingName, hostname, ttl) { function resolver(bindingName) { function query(name, options) { - if (typeof name !== 'string') { - throw new ERR_INVALID_ARG_TYPE('name', 'string', name); - } + validateString(name, 'name'); const ttl = !!(options && options.ttl); return createResolverPromise(this, bindingName, name, ttl); |