-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tls: use optional chaining to simplify checks #41337
Conversation
@@ -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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val?.pem !== undefined ? val.pem : val); | |
val?.pem ?? val); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if val.pem
is null
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using ??
would change the current behavior. If we want to keep this a refactoring, we can't use ??
. Now, if we know that val.pem
can never be null
, we can make that change safely - but maybe in a separate commit?
Landed in f34c0e0 |
PR-URL: #41337 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
PR-URL: #41337 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
PR-URL: nodejs#41337 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
PR-URL: #41337 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Refs: #41170 (review)