From 2ca84381251f3da002dec8e461d1ef1e452187fd Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Wed, 5 Jan 2022 12:01:29 +0100 Subject: [PATCH] tls: use optional chaining to simplify checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/41337 Reviewed-By: Tobias Nießen Reviewed-By: Franziska Hinkelmann --- lib/internal/tls/secure-context.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/internal/tls/secure-context.js b/lib/internal/tls/secure-context.js index d5a447adde84b3..8cb3ae06d2e2e1 100644 --- a/lib/internal/tls/secure-context.js +++ b/lib/internal/tls/secure-context.js @@ -161,11 +161,9 @@ function configSecureContext(context, options = {}, name = 'options') { for (let i = 0; i < key.length; ++i) { const val = key[i]; const pem = ( - val !== undefined && val !== null && - val.pem !== undefined ? val.pem : val); + val?.pem !== undefined ? val.pem : val); const pass = ( - val !== undefined && val !== null && - val.passphrase !== undefined ? val.passphrase : passphrase); + val?.passphrase !== undefined ? val.passphrase : passphrase); setKey(context, pem, pass, name); } } else {