Skip to content

Commit bc2d258

Browse files
committed
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: #27081 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 14df42f commit bc2d258

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/internal/dns/promises.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const {
1010
} = require('internal/dns/utils');
1111
const { codes, dnsException } = require('internal/errors');
1212
const { toASCII } = require('internal/idna');
13-
const { isIP, isIPv4, isLegalPort } = require('internal/net');
13+
const { isIP, isLegalPort } = require('internal/net');
1414
const {
1515
getaddrinfo,
1616
getnameinfo,
@@ -34,7 +34,7 @@ function onlookup(err, addresses) {
3434
return;
3535
}
3636

37-
const family = this.family ? this.family : isIPv4(addresses[0]) ? 4 : 6;
37+
const family = this.family ? this.family : isIP(addresses[0]);
3838
this.resolve({ address: addresses[0], family });
3939
}
4040

@@ -51,7 +51,7 @@ function onlookupall(err, addresses) {
5151

5252
addresses[i] = {
5353
address,
54-
family: family ? family : isIPv4(addresses[i]) ? 4 : 6
54+
family: family ? family : isIP(addresses[i])
5555
};
5656
}
5757

0 commit comments

Comments
 (0)