Skip to content
This repository was archived by the owner on May 31, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/extended-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ const ExtendedConnection = Connection.extend(storageMixin, {
return this.hostname;
}

if (this.hosts && this.hosts.length) {
if (this.hosts && this.hosts.length > 1) {
return this.hosts.map(
({ host, port }) => `${host}:${port}`
).join(',');
}

return this.hostname;
return `${this.hostname}:${this.port}`;
}
}
},
Expand Down
17 changes: 12 additions & 5 deletions test/model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ describe('Connection', () => {

it('returns hosts if the connection is not srv', () => {
assert.strictEqual(
new Connection({ hosts: [{ host: 'example.com', port: 12345 }] }).title,
'example.com:12345'
new Connection({ hosts: [{
host: 'example.com',
port: 12345
}, {
host: 'example123.com',
port: 123452
}] }).title,
'example.com:12345,example123.com:123452'
);
});

Expand All @@ -37,15 +43,16 @@ describe('Connection', () => {
);
});

it('falls back to hostname if nothing else match', () => {
it('falls back to hostname:port if nothing else match', () => {
assert.strictEqual(
new Connection({
isSrvRecord: false,
isFavorite: false,
hosts: [],
hostname: 'somehost'
hostname: 'somehost',
port: 12345
}).title,
'somehost'
'somehost:12345'
);
});
});
Expand Down