Skip to content

Commit 297396b

Browse files
committed
Expose host + port in the parsed URL
It is used as connection identifier i routing table and connection pool.
1 parent 3d0059e commit 297396b

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/v1/internal/url.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ class Url {
4040
*/
4141
this.port = port;
4242

43+
/**
44+
* Nonnull host name or IP address plus port, separated by ':'.
45+
* @type {string}
46+
*/
47+
this.hostAndPort = port ? `${host}:${port}` : host;
48+
4349
/**
4450
* Nonnull object representing parsed query string key-value pairs. Duplicated keys not supported.
4551
* @type {object}

test/internal/url.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,10 @@ fdescribe('url', () => {
622622

623623
if (expectedUrl.port) {
624624
expect(url.port).toEqual(expectedUrl.port);
625+
expect(url.hostAndPort).toEqual(`${expectedUrl.host}:${expectedUrl.port}`);
625626
} else {
626627
expect(url.port).toBeNull();
628+
expect(url.hostAndPort).toEqual(expectedUrl.host);
627629
}
628630

629631
if (expectedUrl.query) {

0 commit comments

Comments
 (0)