From f97e27f0c05f325d18d86115d3998cc3755bc7df Mon Sep 17 00:00:00 2001 From: Michael Lumish Date: Tue, 16 Jun 2020 11:40:22 -0700 Subject: [PATCH] Fix possible null reference --- packages/grpc-js/src/call-credentials-filter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/grpc-js/src/call-credentials-filter.ts b/packages/grpc-js/src/call-credentials-filter.ts index a5459b53..5263d97f 100644 --- a/packages/grpc-js/src/call-credentials-filter.ts +++ b/packages/grpc-js/src/call-credentials-filter.ts @@ -39,7 +39,7 @@ export class CallCredentialsFilter extends BaseFilter implements Filter { if (splitPath.length >= 2) { serviceName = splitPath[1]; } - const hostname = splitHostPort(stream.getHost()).host; + const hostname = splitHostPort(stream.getHost())?.host ?? 'localhost'; /* Currently, call credentials are only allowed on HTTPS connections, so we * can assume that the scheme is "https" */ this.serviceUrl = `https://${hostname}/${serviceName}`;