From d9c2119ac67d45888ac527b575016b8b28a5afa6 Mon Sep 17 00:00:00 2001 From: rickyes Date: Sun, 5 Apr 2020 16:57:13 +0800 Subject: [PATCH 1/2] dns: remove duplicate code --- lib/dns.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/dns.js b/lib/dns.js index bd330ba92bc1d6..260e32699e0526 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -65,11 +65,9 @@ function onlookup(err, addresses) { if (err) { return this.callback(dnsException(err, 'getaddrinfo', this.hostname)); } - if (this.family) { - this.callback(null, addresses[0], this.family); - } else { - this.callback(null, addresses[0], isIP(addresses[0])); - } + this.callback(null, addresses[0], this.family ? + this.family : + isIP(addresses[0])); } From 78dae08b86dba78df3f698b1d110164c9df66068 Mon Sep 17 00:00:00 2001 From: rickyes Date: Sun, 5 Apr 2020 17:46:25 +0800 Subject: [PATCH 2/2] dns: remove duplicate code --- lib/dns.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/dns.js b/lib/dns.js index 260e32699e0526..4243a05e179b88 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -65,9 +65,7 @@ function onlookup(err, addresses) { if (err) { return this.callback(dnsException(err, 'getaddrinfo', this.hostname)); } - this.callback(null, addresses[0], this.family ? - this.family : - isIP(addresses[0])); + this.callback(null, addresses[0], this.family || isIP(addresses[0])); }