mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 17:01:08 +00:00

When the second argument to `assert.throws()` is a string, it is not treated as the expected error message but rather the message that the assertion should display if no error is thrown. Ths change fixes that error in `test-http-invalid-urls.js`. Instead of skipping the test when there is no crypto, the test is now run but with `http` only. `https` is skipped. Logging was fixed. Previously, errors would be written out as being in the `[object Object]` module rather than `http` or `https`. PR-URL: https://github.com/nodejs/node/pull/15678 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
28 lines
690 B
JavaScript
28 lines
690 B
JavaScript
/* eslint-disable crypto-check */
|
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
const http = require('http');
|
|
const modules = { 'http': http };
|
|
|
|
if (common.hasCrypto) {
|
|
const https = require('https');
|
|
modules.https = https;
|
|
}
|
|
|
|
function test(host) {
|
|
['get', 'request'].forEach((fn) => {
|
|
Object.keys(modules).forEach((module) => {
|
|
const doNotCall = common.mustNotCall(
|
|
`${module}.${fn} should not connect to ${host}`
|
|
);
|
|
const throws = () => { modules[module][fn](host, doNotCall); };
|
|
common.expectsError(throws, { code: 'ERR_INVALID_DOMAIN_NAME' });
|
|
});
|
|
});
|
|
}
|
|
|
|
['www.nodejs.org', 'localhost', '127.0.0.1', 'http://:80/'].forEach(test);
|