http: default Agent.getName to 'localhost'
authorMalcolm Ahoy <malcolmahoy@gmail.com>
Fri, 11 Sep 2015 21:18:01 +0000 (14:18 -0700)
committerJeremiah Senkpiel <fishrock123@rocketmail.com>
Wed, 16 Sep 2015 15:40:59 +0000 (11:40 -0400)
Refactor out the if/else statement checking for option.host.
Add whitespace to make concatenation chunks more readable and
consistent with the https version of Agent.getName().

PR-URL: https://github.com/nodejs/node/pull/2825
Reviewed-By: Julian Duque <julianduquej@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
lib/_http_agent.js

index 1db331c..c18f39a 100644 (file)
@@ -94,19 +94,16 @@ Agent.prototype.createConnection = net.createConnection;
 
 // Get the key for a given set of request options
 Agent.prototype.getName = function(options) {
-  var name = '';
-
-  if (options.host)
-    name += options.host;
-  else
-    name += 'localhost';
+  var name = options.host || 'localhost';
 
   name += ':';
   if (options.port)
     name += options.port;
+
   name += ':';
   if (options.localAddress)
     name += options.localAddress;
+
   return name;
 };