Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe('HttpServer (integration)', () => {
.to.have.property('address')
.which.is.an.Object();
await server.stop();
expect(server.address).to.be.undefined();
expect(server.address).to.be.null();
});

it('exports listening', async () => {
Expand Down
12 changes: 6 additions & 6 deletions packages/http-server/src/http-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export type HttpProtocol = 'http' | 'https'; // Will be extended to `http2` in t
export class HttpServer {
private _listening: boolean = false;
private _protocol: HttpProtocol;
private _address: string | AddressInfo;
private _address: string | AddressInfo | null;
private requestListener: RequestListener;
readonly server: http.Server | https.Server;
private serverOptions: HttpServerOptions;
Expand Down Expand Up @@ -132,12 +132,12 @@ export class HttpServer {
* URL of the HTTP / HTTPS server
*/
public get url(): string {
if (typeof this._address === 'string') {
if (typeof this._address === 'string' || this._address == null) {
/* istanbul ignore if */
if (isWin32()) {
return this._address;
return this._address || '';
}
const basePath = encodeURIComponent(this._address);
const basePath = encodeURIComponent(this._address || '');
return `${this.protocol}+unix://${basePath}`;
}
let host = this.host;
Expand All @@ -160,8 +160,8 @@ export class HttpServer {
/**
* Address of the HTTP / HTTPS server
*/
public get address(): string | AddressInfo | undefined {
return this._listening ? this._address : undefined;
public get address(): string | AddressInfo | null {
return this._listening ? this._address : null;
}
}

Expand Down