mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08:00
Replace `Array.prototype.forEach()` with `for...of` loops across 17 tests in `test/parallel`, so each loop body reads as a plain statement rather than an arrow callback. None of the iterated values are sparse arrays, the one case where `forEach` and `for...of` genuinely differ, so both constructs visit the same elements in the same order. No callback relied on `this`, an early return, or async behaviour, and the number of assertions run in each file is unchanged. Signed-off-by: Phillip Markert <phillip@ephisys.com> PR-URL: https://github.com/nodejs/node/pull/65272 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
29 lines
742 B
JavaScript
29 lines
742 B
JavaScript
/* eslint-disable node-core/crypto-check */
|
|
// Flags: --expose-internals
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
const { kOutHeaders } = require('internal/http');
|
|
|
|
const http = require('http');
|
|
const modules = { http };
|
|
|
|
if (common.hasCrypto) {
|
|
const https = require('https');
|
|
modules.https = https;
|
|
}
|
|
|
|
for (const module of Object.keys(modules)) {
|
|
const doNotCall = common.mustNotCall(
|
|
`${module}.request should not connect to ${module}://example.com%60x.example.com`
|
|
);
|
|
const req = modules[module].request(`${module}://example.com%60x.example.com`, doNotCall);
|
|
assert.deepStrictEqual(req[kOutHeaders].host, [
|
|
'Host',
|
|
'example.com`x.example.com',
|
|
]);
|
|
req.abort();
|
|
};
|