Skip to content

Commit cd700ff

Browse files
trivikrBethGriggs
authored andcommitted
tls: for...of in _tls_common.js
PR-URL: #30961 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent a9fad85 commit cd700ff

3 files changed

Lines changed: 14 additions & 22 deletions

File tree

‎lib/_tls_common.js‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,12 @@ exports.createSecureContext = function createSecureContext(options) {
100100

101101
constc=newSecureContext(options.secureProtocol,secureOptions,
102102
options.minVersion,options.maxVersion);
103-
leti;
104-
letval;
105103

106104
// Add CA before the cert to be able to load cert's issuer in C++ code.
107105
const{ ca }=options;
108106
if(ca){
109107
if(ArrayIsArray(ca)){
110-
for(i=0;i<ca.length;++i){
111-
val=ca[i];
108+
for(constvalofca){
112109
validateKeyOrCertOption('ca',val);
113110
c.context.addCACert(val);
114111
}
@@ -123,8 +120,7 @@ exports.createSecureContext = function createSecureContext(options) {
123120
const{ cert }=options;
124121
if(cert){
125122
if(ArrayIsArray(cert)){
126-
for(i=0;i<cert.length;++i){
127-
val=cert[i];
123+
for(constvalofcert){
128124
validateKeyOrCertOption('cert',val);
129125
c.context.setCert(val);
130126
}
@@ -142,8 +138,7 @@ exports.createSecureContext = function createSecureContext(options) {
142138
constpassphrase=options.passphrase;
143139
if(key){
144140
if(ArrayIsArray(key)){
145-
for(i=0;i<key.length;++i){
146-
val=key[i];
141+
for(constvalofkey){
147142
// eslint-disable-next-line eqeqeq
148143
constpem=(val!=undefined&&val.pem!==undefined ? val.pem : val);
149144
validateKeyOrCertOption('key',pem);
@@ -242,8 +237,8 @@ exports.createSecureContext = function createSecureContext(options) {
242237

243238
if(options.crl){
244239
if(ArrayIsArray(options.crl)){
245-
for(i=0;i<options.crl.length;i++){
246-
c.context.addCRL(options.crl[i]);
240+
for(constcrlofoptions.crl){
241+
c.context.addCRL(crl);
247242
}
248243
}else{
249244
c.context.addCRL(options.crl);
@@ -259,8 +254,7 @@ exports.createSecureContext = function createSecureContext(options) {
259254
toBuf=require('internal/crypto/util').toBuf;
260255

261256
if(ArrayIsArray(options.pfx)){
262-
for(i=0;i<options.pfx.length;i++){
263-
constpfx=options.pfx[i];
257+
for(constpfxofoptions.pfx){
264258
constraw=pfx.buf ? pfx.buf : pfx;
265259
constbuf=toBuf(raw);
266260
constpassphrase=pfx.passphrase||options.passphrase;

‎lib/_tls_wrap.js‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,9 @@ function makeMethodProxy(name) {
530530
returnthis._parent[name].apply(this._parent,args);
531531
};
532532
}
533-
for(letn=0;n<proxiedMethods.length;n++){
534-
tls_wrap.TLSWrap.prototype[proxiedMethods[n]]=
535-
makeMethodProxy(proxiedMethods[n]);
533+
for(constproxiedMethodofproxiedMethods){
534+
tls_wrap.TLSWrap.prototype[proxiedMethod]=
535+
makeMethodProxy(proxiedMethod);
536536
}
537537

538538
tls_wrap.TLSWrap.prototype.close=functionclose(cb){
@@ -1412,8 +1412,7 @@ Server.prototype[EE.captureRejectionSymbol] = function(
14121412
functionSNICallback(servername,callback){
14131413
constcontexts=this.server._contexts;
14141414

1415-
for(leti=0;i<contexts.length;i++){
1416-
constelem=contexts[i];
1415+
for(constelemofcontexts){
14171416
if(elem[0].test(servername)){
14181417
callback(null,elem[1]);
14191418
return;

‎lib/internal/tls.js‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ const {
99
// C=US\nST=CA\nL=SF\nO=Joyent\nOU=Node.js\nCN=ca1\nemailAddress=ry@clouds.org
1010
functionparseCertString(s){
1111
constout=ObjectCreate(null);
12-
constparts=s.split('\n');
13-
for(leti=0,len=parts.length;i<len;i++){
14-
constsepIndex=parts[i].indexOf('=');
12+
for(constpartofs.split('\n')){
13+
constsepIndex=part.indexOf('=');
1514
if(sepIndex>0){
16-
constkey=parts[i].slice(0,sepIndex);
17-
constvalue=parts[i].slice(sepIndex+1);
15+
constkey=part.slice(0,sepIndex);
16+
constvalue=part.slice(sepIndex+1);
1817
if(keyinout){
1918
if(!ArrayIsArray(out[key])){
2019
out[key]=[out[key]];

0 commit comments

Comments
 (0)