Skip to content

Commit 5c67085

Browse files
VoltrexKeyvaBethGriggs
authored andcommittedSep 21, 2021
dns: cleanup validation
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>
1 parent 7fdb127 commit 5c67085

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed
 

‎lib/internal/dns/utils.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ const IPv6RE = /^\[([^[\]]*)\]/;
3232
const addrSplitRE = /(^.+?)(?::(\d+))?$/;
3333
const {
3434
ERR_DNS_SET_SERVERS_FAILED,
35-
ERR_INVALID_ARG_TYPE,
3635
ERR_INVALID_ARG_VALUE,
3736
ERR_INVALID_IP_ADDRESS,
3837
} = errors.codes;
@@ -131,8 +130,8 @@ class Resolver {
131130
setLocalAddress(ipv4, ipv6) {
132131
validateString(ipv4, 'ipv4');
133132

134-
if (typeof ipv6 !== 'string' && ipv6 !== undefined) {
135-
throw new ERR_INVALID_ARG_TYPE('ipv6', ['String', 'undefined'], ipv6);
133+
if (ipv6 !== undefined) {
134+
validateString(ipv6, 'ipv6');
136135
}
137136

138137
this._handle.setLocalAddress(ipv4, ipv6);

0 commit comments

Comments
 (0)