1/* eslint-disable node-core/crypto-check */ 2 3'use strict'; 4 5const common = require('../common'); 6 7const assert = require('assert'); 8const http = require('http'); 9const modules = { 'http': http }; 10 11if (common.hasCrypto) { 12 const https = require('https'); 13 modules.https = https; 14} 15 16function test(host) { 17 ['get', 'request'].forEach((fn) => { 18 Object.keys(modules).forEach((module) => { 19 const doNotCall = common.mustNotCall( 20 `${module}.${fn} should not connect to ${host}` 21 ); 22 const throws = () => { modules[module][fn](host, doNotCall); }; 23 assert.throws(throws, { 24 name: 'TypeError', 25 code: 'ERR_INVALID_URL' 26 }); 27 }); 28 }); 29} 30 31['www.nodejs.org', 'localhost', '127.0.0.1', 'http://:80/'].forEach(test); 32