Browse Source

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.
v0.7.4-release
isaacs 14 years ago
parent
commit
580ab7ba2c
  1. 4
      lib/http.js

4
lib/http.js

@ -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…
Cancel
Save