mirror of
https://github.com/nodejs/node.git
synced 2025-08-16 06:08:50 +02:00

Changes the base instance for ERR_INVALID_DOMAIN_NAME from Error to TypeError as a more accurate representation of the error. PR-URL: https://github.com/nodejs/node/pull/19961 Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
30 lines
739 B
JavaScript
30 lines
739 B
JavaScript
/* eslint-disable node-core/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, {
|
|
type: TypeError,
|
|
code: 'ERR_INVALID_DOMAIN_NAME'
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
['www.nodejs.org', 'localhost', '127.0.0.1', 'http://:80/'].forEach(test);
|