From 5c6708582eea2839ae2fb8b9013ae9ee51a75720 Mon Sep 17 00:00:00 2001 From: Voltrex Date: Fri, 10 Sep 2021 08:49:58 +0430 Subject: [PATCH] dns: cleanup validation The `validateString()` validator should cleanup the validation and keep consistency. PR-URL: https://github.com/nodejs/node/pull/40061 Reviewed-By: Antoine du Hamel Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- lib/internal/dns/utils.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/internal/dns/utils.js b/lib/internal/dns/utils.js index f15f8c7a779ce1..8fd5e2018f2d9c 100644 --- a/lib/internal/dns/utils.js +++ b/lib/internal/dns/utils.js @@ -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; @@ -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);