mirror of https://github.com/nodejs/node.git
Avoid instanceof for native object types
For classes defined in the module, this is fine. For 'Error' it's probably not very hazardous. However, testing 'Object' and 'String' is much more reliable using typeof, to work with the repl and NODE_MODULE_CONTEXT modes.pull/5370/head
parent
e142fe2be6
commit
580ab7ba2c
|
@ -1437,12 +1437,12 @@ function getAgent(options) {
|
|||
|
||||
var _opts = {};
|
||||
|
||||
if (options instanceof String) {
|
||||
if (typeof options === 'string') {
|
||||
port = arguments[1] || 80;
|
||||
id = options + ':' + port;
|
||||
_opts.host = options;
|
||||
_opts.port = port;
|
||||
} else if (options instanceof Object) {
|
||||
} else if (options && options === 'object') {
|
||||
if (options.port || options.host) {
|
||||
host = options.host || 'localhost';
|
||||
port = options.port || 80;
|
||||
|
|
Loading…
Reference in New Issue