diff options
author | Rich Trott <rtrott@gmail.com> | 2019-04-03 17:07:15 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-04-16 16:19:14 -0700 |
commit | bc2d258a3ee8266a6e54cb023b98d6993e72bab1 (patch) | |
tree | 2b7e53712c00f28f0097d036266026141b5779d6 /lib/internal/dns | |
parent | 14df42fd008ef8e95d60d0d70084943d180bab91 (diff) | |
download | android-node-v8-bc2d258a3ee8266a6e54cb023b98d6993e72bab1.tar.gz android-node-v8-bc2d258a3ee8266a6e54cb023b98d6993e72bab1.tar.bz2 android-node-v8-bc2d258a3ee8266a6e54cb023b98d6993e72bab1.zip |
dns: refactor internal/dns/promises.js
Use `isIP()` instead of `isIPv4()` since it does the additional
functionality that we were adding after our calls to `isIP()`.
This not-so-incidentally also increases code coverage from tests. At
least one of the replaced ternaries was difficult to cover reliably
because operating system/configuration variances were too unpredictable.
PR-URL: https://github.com/nodejs/node/pull/27081
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'lib/internal/dns')
-rw-r--r-- | lib/internal/dns/promises.js | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/internal/dns/promises.js b/lib/internal/dns/promises.js index cd4607f485..2969721355 100644 --- a/lib/internal/dns/promises.js +++ b/lib/internal/dns/promises.js @@ -10,7 +10,7 @@ const { } = require('internal/dns/utils'); const { codes, dnsException } = require('internal/errors'); const { toASCII } = require('internal/idna'); -const { isIP, isIPv4, isLegalPort } = require('internal/net'); +const { isIP, isLegalPort } = require('internal/net'); const { getaddrinfo, getnameinfo, @@ -34,7 +34,7 @@ function onlookup(err, addresses) { return; } - const family = this.family ? this.family : isIPv4(addresses[0]) ? 4 : 6; + const family = this.family ? this.family : isIP(addresses[0]); this.resolve({ address: addresses[0], family }); } @@ -51,7 +51,7 @@ function onlookupall(err, addresses) { addresses[i] = { address, - family: family ? family : isIPv4(addresses[i]) ? 4 : 6 + family: family ? family : isIP(addresses[i]) }; } |