Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
dns: cleanup validation
The `validateString()` validator should cleanup the validation and
keep consistency.
  • Loading branch information
VoltrexKeyva committed Sep 10, 2021
commit e65a1268d0c5035ad0e8ecfb181fec49746b6c40
5 changes: 2 additions & 3 deletions lib/internal/dns/utils.js
Original file line number Diff line number Diff line change
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,8 +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');
Comment thread
VoltrexKeyva marked this conversation as resolved.
Outdated
}

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