Skip to content

Commit

Permalink
dns: cleanup validation
Browse files Browse the repository at this point in the history
The `validateString()` validator should cleanup the validation and
keep consistency.
  • Loading branch information
VoltrexKeyva committed Sep 10, 2021
1 parent a42bd7e commit 3a13bf1
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/internal/dns/utils.js
Expand Up @@ -32,7 +32,6 @@ const IPv6RE = /^\[([^[\]]*)\]/;
const addrSplitRE = /(^.+?)(?::(\d+))?$/;
const {
ERR_DNS_SET_SERVERS_FAILED,
ERR_INVALID_ARG_TYPE,
ERR_INVALID_ARG_VALUE,
ERR_INVALID_IP_ADDRESS,
} = errors.codes;
Expand Down Expand Up @@ -131,9 +130,8 @@ class Resolver {
setLocalAddress(ipv4, ipv6) {
validateString(ipv4, 'ipv4');

if (typeof ipv6 !== 'string' && ipv6 !== undefined) {
throw new ERR_INVALID_ARG_TYPE('ipv6', ['String', 'undefined'], ipv6);
}
if (ipv6 !== undefined)
validateString(ipv6, 'ipv6');

this._handle.setLocalAddress(ipv4, ipv6);
}
Expand Down

0 comments on commit 3a13bf1

Please sign in to comment.