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.

PR-URL: #40061
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
VoltrexKeyva authored and BethGriggs committed Sep 21, 2021
1 parent edec15b commit 8138647
Showing 1 changed file with 2 additions and 3 deletions.
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');
}

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

0 comments on commit 8138647

Please sign in to comment.