diff --git a/lib/_http_agent.js b/lib/_http_agent.js index 9208044a940afd..1db331c3d12aa6 100644 --- a/lib/_http_agent.js +++ b/lib/_http_agent.js @@ -107,7 +107,6 @@ Agent.prototype.getName = function(options) { name += ':'; if (options.localAddress) name += options.localAddress; - name += ':'; return name; }; diff --git a/test/parallel/test-http-agent-getname.js b/test/parallel/test-http-agent-getname.js new file mode 100644 index 00000000000000..d8d30a8ddbc25c --- /dev/null +++ b/test/parallel/test-http-agent-getname.js @@ -0,0 +1,32 @@ +'use strict'; + +var assert = require('assert'); +var http = require('http'); +var common = require('../common'); + +var agent = new http.Agent(); + +// default to localhost +assert.equal( + agent.getName({ + port: 80, + localAddress: '192.168.1.1' + }), + 'localhost:80:192.168.1.1' +); + +// empty +assert.equal( + agent.getName({}), + 'localhost::' +); + +// pass all arguments +assert.equal( + agent.getName({ + host: '0.0.0.0', + port: 80, + localAddress: '192.168.1.1' + }), + '0.0.0.0:80:192.168.1.1' +); diff --git a/test/parallel/test-http-agent-keepalive.js b/test/parallel/test-http-agent-keepalive.js index f82af380bce1a9..ef9553c8316841 100644 --- a/test/parallel/test-http-agent-keepalive.js +++ b/test/parallel/test-http-agent-keepalive.js @@ -35,7 +35,7 @@ function get(path, callback) { }, callback); } -var name = 'localhost:' + common.PORT + '::'; +var name = 'localhost:' + common.PORT + ':'; function checkDataAndSockets(body) { assert.equal(body.toString(), 'hello world');