diff --git a/packages/grpcweb-transport/src/grpc-web-format.ts b/packages/grpcweb-transport/src/grpc-web-format.ts index f0dfee66..b435e3e6 100644 --- a/packages/grpcweb-transport/src/grpc-web-format.ts +++ b/packages/grpcweb-transport/src/grpc-web-format.ts @@ -300,9 +300,11 @@ function parseMetadata(headers: HttpHeaders): RpcMetadata { function parseTrailer(trailerData: Uint8Array): HttpHeaders { let headers: HttpHeaders = {}; for (let chunk of String.fromCharCode.apply(String, trailerData as unknown as number[]).trim().split("\r\n")) { - let [key, value] = chunk.split(":", 2); + if (chunk == "") + continue; + let [key, ...val] = chunk.split(":"); + const value = val.join(":").trim(); key = key.trim(); - value = value.trim(); let e = headers[key]; if (typeof e == "string") headers[key] = [e, value];