mirror of https://github.com/nodejs/node.git
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)").archived-io.js-v0.10
parent
56e80a37e0
commit
2ee86c624e
|
@ -184,9 +184,11 @@ exports.resolve = function(domain, type_, callback_) {
|
||||||
if (typeof type_ == 'string') {
|
if (typeof type_ == 'string') {
|
||||||
resolver = resolveMap[type_];
|
resolver = resolveMap[type_];
|
||||||
callback = callback_;
|
callback = callback_;
|
||||||
} else {
|
} else if (util.isFunction(type_)) {
|
||||||
resolver = exports.resolve4;
|
resolver = exports.resolve4;
|
||||||
callback = type_;
|
callback = type_;
|
||||||
|
} else {
|
||||||
|
throw new Error('Type must be a string')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof resolver === 'function') {
|
if (typeof resolver === 'function') {
|
||||||
|
|
Loading…
Reference in New Issue