diff options
author | Kenan Sulayman <kenan@sly.mn> | 2014-02-07 18:18:27 +0100 |
---|---|---|
committer | Fedor Indutny <fedor.indutny@gmail.com> | 2014-02-08 02:10:01 +0400 |
commit | 2ee86c624ecd6b9dbaad10989143325fc64778cd (patch) | |
tree | e49a9445dcce3f2eedd395d403174893d9b3a950 | |
parent | 56e80a37e0df0d131d3a3ad6426d52f887ef8e94 (diff) | |
download | node-new-2ee86c624ecd6b9dbaad10989143325fc64778cd.tar.gz |
dns: verify argument is valid function in resolve
Don't use argument as callback if it's not a valid callback function.
Throw a valid exception instead explaining the issue. Adds to #7070
("DNS — Throw meaningful error(s)").
-rw-r--r-- | lib/dns.js | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/dns.js b/lib/dns.js index 15ee6a4362..dcf2128e28 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -184,9 +184,11 @@ exports.resolve = function(domain, type_, callback_) { if (typeof type_ == 'string') { resolver = resolveMap[type_]; callback = callback_; - } else { + } else if (util.isFunction(type_)) { resolver = exports.resolve4; callback = type_; + } else { + throw new Error('Type must be a string') } if (typeof resolver === 'function') { |