diff --git a/packages/http-server/src/__tests__/integration/http-server.integration.ts b/packages/http-server/src/__tests__/integration/http-server.integration.ts index ced00deeec59..2727c67e6a5d 100644 --- a/packages/http-server/src/__tests__/integration/http-server.integration.ts +++ b/packages/http-server/src/__tests__/integration/http-server.integration.ts @@ -29,7 +29,7 @@ describe('HttpServer (integration)', () => { host: '::1', } as HttpOptions); await server.start(); - expect(getAddressFamily(server)).to.equal('IPv6'); + expect(getAddressFamily(server)).to.equalOneOf(6, 'IPv6'); const response = await httpGetAsync(server.url); expect(response.statusCode).to.equal(200); }); @@ -225,7 +225,7 @@ describe('HttpServer (integration)', () => { it('supports HTTP over IPv4', async () => { server = new HttpServer(dummyRequestHandler, {host: '127.0.0.1'}); await server.start(); - expect(getAddressFamily(server)).to.equal('IPv4'); + expect(getAddressFamily(server)).to.equalOneOf(4, 'IPv4'); const response = await httpGetAsync(server.url); expect(response.statusCode).to.equal(200); }); @@ -233,7 +233,7 @@ describe('HttpServer (integration)', () => { skipOnTravis(it, 'supports HTTP over IPv6', async () => { server = new HttpServer(dummyRequestHandler, {host: '::1'}); await server.start(); - expect(getAddressFamily(server)).to.equal('IPv6'); + expect(getAddressFamily(server)).to.equalOneOf(6, 'IPv6'); const response = await httpGetAsync(server.url); expect(response.statusCode).to.equal(200); }); @@ -258,7 +258,7 @@ describe('HttpServer (integration)', () => { host: '::1', }); await httpsServer.start(); - expect(getAddressFamily(httpsServer)).to.equal('IPv6'); + expect(getAddressFamily(httpsServer)).to.equalOneOf(6, 'IPv6'); const response = await httpsGetAsync(httpsServer.url); expect(response.statusCode).to.equal(200); }); diff --git a/packages/http-server/src/http-server.ts b/packages/http-server/src/http-server.ts index ac6efee3ea8a..bf4ee286b4fe 100644 --- a/packages/http-server/src/http-server.ts +++ b/packages/http-server/src/http-server.ts @@ -231,7 +231,7 @@ export class HttpServer { return `${this.protocol}+unix://${basePath}`; } let host = this.host; - if (this._address.family === 'IPv6') { + if ([6, 'IPv6'].includes(this._address.family)) { if (host === '::') host = '::1'; host = `[${host}]`; } else if (host === '0.0.0.0') {