Skip to content

Commit 431bf74

Browse files
ahoymFishrock123
authored andcommitted
http: default Agent.getName to 'localhost'
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: #2825 Reviewed-By: Julian Duque <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 0a5f80a commit 431bf74

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/_http_agent.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,16 @@ Agent.prototype.createConnection = net.createConnection;
9494

9595
// Get the key for a given set of request options
9696
Agent.prototype.getName = function(options) {
97-
var name = '';
98-
99-
if (options.host)
100-
name += options.host;
101-
else
102-
name += 'localhost';
97+
var name = options.host || 'localhost';
10398

10499
name += ':';
105100
if (options.port)
106101
name += options.port;
102+
107103
name += ':';
108104
if (options.localAddress)
109105
name += options.localAddress;
106+
110107
return name;
111108
};
112109

0 commit comments

Comments
 (0)