Skip to content

Commit

Permalink
http: fix agent.getName() and add tests
Browse files Browse the repository at this point in the history
This commit fixes agent.getName(), which returned an extra colon
according to the docs, and adds tests (it was previously not unit
tested).
  • Loading branch information
brendanashworth committed May 5, 2015
1 parent 7dde95a commit 74c3cc5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/_http_agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ Agent.prototype.getName = function(options) {
name += ':';
if (options.localAddress)
name += options.localAddress;
name += ':';
return name;
};

Expand Down
30 changes: 30 additions & 0 deletions test/parallel/test-http-agent-getname.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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'
);

0 comments on commit 74c3cc5

Please sign in to comment.