Skip to content

Commit

Permalink
Fix parseHost returning a string port instead of a number closes #1229
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperlink committed Apr 30, 2019
1 parent 7ee0583 commit d089ad0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/kafkaClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ util.inherits(KafkaClient, Client);

function parseHost (hostString) {
const ip = hostString.substring(0, hostString.lastIndexOf(':'));
const port = hostString.substring(hostString.lastIndexOf(':') + 1);
const port = +hostString.substring(hostString.lastIndexOf(':') + 1);
const isIpv6 = ip.match(/\[(.*)\]/);
const host = isIpv6 ? isIpv6[1] : ip;
return {
Expand Down
8 changes: 4 additions & 4 deletions test/test.kafkaClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe('Kafka Client', function () {
client.initialHosts.should.not.be.empty;
client.initialHosts.length.should.be.eql(1);
client.initialHosts[0].host.should.be.eql('localhost');
client.initialHosts[0].port.should.be.eql('9092');
client.initialHosts[0].port.should.be.eql(9092);
});

it('initial hosts should be parsed if multiple hosts are provided', function () {
Expand All @@ -146,15 +146,15 @@ describe('Kafka Client', function () {
client.initialHosts.should.be.eql([
{
host: 'localhost',
port: '9092'
port: 9092
},
{
host: '127.0.0.1',
port: '9093'
port: 9093
},
{
host: '192.168.1.0',
port: '9094'
port: 9094
}
]);
});
Expand Down

0 comments on commit d089ad0

Please sign in to comment.