From c368bfea3f486d6ebcc5de1e518f487b4eaafe95 Mon Sep 17 00:00:00 2001 From: Steve-Mcl Date: Sun, 17 Mar 2024 12:37:42 +0000 Subject: [PATCH] var/const updates --- .../@node-red/nodes/core/network/21-httprequest.js | 13 +++---------- test/nodes/core/network/lib/proxyHelper_spec.js | 8 ++++---- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js b/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js index 572c6ff17..79af8a4ba 100644 --- a/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js +++ b/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js @@ -515,20 +515,13 @@ in your Node-RED user directory (${RED.settings.userDir}). opts.headers['user-agent'] = 'Mozilla/5.0 (Node-RED)'; } if (proxyUrl) { - var match = proxyUrl.match(/^(https?:\/\/)?(.+)?:([0-9]+)?/i); + const match = proxyUrl.match(/^(https?:\/\/)?(.+)?:([0-9]+)?/i); if (match) { const proxyURL = parseUrl(proxyUrl) //set username/password to null to stop empty creds header - /** @type {HttpProxyAgentOptions} */ + /** @type {import('hpagent').HttpProxyAgentOptions} */ let proxyOptions = { proxy: proxyUrl, - // proxy: { - // protocol: proxyURL.protocol, - // hostname: proxyURL.hostname, - // port: proxyURL.port, - // username: null, - // password: null - // }, scheduling: 'lifo', maxFreeSockets: 256, maxSockets: 256, @@ -554,7 +547,7 @@ in your Node-RED user directory (${RED.settings.userDir}). }; } else { - node.warn("Bad proxy url: "+ proxyUrl); + node.warn("Bad proxy url: " + proxyUrl); } } if (tlsNode) { diff --git a/test/nodes/core/network/lib/proxyHelper_spec.js b/test/nodes/core/network/lib/proxyHelper_spec.js index 5ad42a42f..4cbebef7f 100644 --- a/test/nodes/core/network/lib/proxyHelper_spec.js +++ b/test/nodes/core/network/lib/proxyHelper_spec.js @@ -70,11 +70,11 @@ function testProxyUrl(env, expected, input, options) { // the call of this function and the use of it below. env = JSON.parse(JSON.stringify(env)); - var title = 'getProxyForUrl(' + JSON.stringify(input) + ')' + + const title = 'getProxyForUrl(' + JSON.stringify(input) + ')' + ' === ' + JSON.stringify(expected); // Save call stack for later use. - var stack = {}; + const stack = {}; Error.captureStackTrace(stack, testProxyUrl); // Only use the last stack frame because that shows where this function is // called, and that is sufficient for our purpose. No need to flood the logs @@ -82,7 +82,7 @@ function testProxyUrl(env, expected, input, options) { stack = stack.stack.split('\n', 2)[1]; it(title, function () { - var actual; + let actual; // runWithEnv(env, function () { // actual = getProxyForUrl(input, options); // }); @@ -105,7 +105,7 @@ function testProxyUrl(env, expected, input, options) { }); } -describe('Proxy Helper', function () { +describe.only('Proxy Helper', function () { describe('No proxy variables', function () { const env = {}; testProxyUrl(env, '', 'http://example.com');