GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — dns: refactor and use validators · nodejs/node@7c77db0

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/dns
    • promises.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/dns/promises.js‎

Copy file name to clipboardExpand all lines: lib/internal/dns/promises.js
+11-10Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const {
2929
QueryReqWrap
3030
} = internalBinding('cares_wrap');
3131
const {
32-
ERR_INVALID_ARG_TYPE,
3332
ERR_INVALID_ARG_VALUE,
3433
ERR_MISSING_ARGS,
3534
} = codes;
@@ -45,7 +44,7 @@ function onlookup(err, addresses) {
4544
return;
4645
}
4746

48-
const family = this.family ? this.family : isIP(addresses[0]);
47+
const family = this.family || isIP(addresses[0]);
4948
this.resolve({ address: addresses[0], family });
5049
}
5150

@@ -62,7 +61,7 @@ function onlookupall(err, addresses) {
6261

6362
addresses[i] = {
6463
address,
65-
family: family ? family : isIP(addresses[i])
64+
family: family || isIP(addresses[i])
6665
};
6766
}
6867

@@ -108,9 +107,11 @@ function lookup(hostname, options) {
108107
var verbatim = getDefaultVerbatim();
109108

110109
// Parse arguments
111-
if (hostname && typeof hostname !== 'string') {
112-
throw new ERR_INVALID_ARG_TYPE('hostname', 'string', hostname);
113-
} else if (options !== null && typeof options === 'object') {
110+
if (hostname) {
111+
validateString(hostname, 'hostname');
112+
}
113+
114+
if (options !== null && typeof options === 'object') {
114115
if (options.hints != null && typeof options.hints !== 'number') {
115116
emitTypeCoercionDeprecationWarning();
116117
}
@@ -257,15 +258,15 @@ Resolver.prototype.reverse = resolver('getHostByAddr');
257258
Resolver.prototype.resolve = function resolve(hostname, rrtype) {
258259
var resolver;
259260

260-
if (typeof rrtype === 'string') {
261+
if (rrtype !== undefined) {
262+
validateString(rrtype, 'rrtype');
263+
261264
resolver = resolveMap[rrtype];
262265

263266
if (typeof resolver !== 'function')
264267
throw new ERR_INVALID_ARG_VALUE('rrtype', rrtype);
265-
} else if (rrtype === undefined) {
266-
resolver = resolveMap.A;
267268
} else {
268-
throw new ERR_INVALID_ARG_TYPE('rrtype', 'string', rrtype);
269+
resolver = resolveMap.A;
269270
}
270271

271272
return ReflectApply(resolver, this, [hostname]);

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.