| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent da40050 commit 2e215f1
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,20 +1,25 @@ | |||
| 1 | + /* eslint-disable crypto-check */ | ||
| 2 | + | ||
| 1 | 3 | 'use strict'; | |
| 2 | 4 | ||
| 3 | 5 | const common = require('../common'); | |
| 4 | - if (!common.hasCrypto) | ||
| 5 | - common.skip('missing crypto'); | ||
| 6 | 6 | ||
| 7 | - const assert = require('assert'); | ||
| 8 | 7 | const http = require('http'); | |
| 9 | - const https = require('https'); | ||
| 10 | - const error = 'Unable to determine the domain name'; | ||
| 8 | + const modules = { 'http': http }; | ||
| 9 | + | ||
| 10 | + if (common.hasCrypto) { | ||
| 11 | + const https = require('https'); | ||
| 12 | + modules.https = https; | ||
| 13 | + } | ||
| 11 | 14 | ||
| 12 | 15 | function test(host) { | |
| 13 | - ['get', 'request'].forEach((method) => { | ||
| 14 | - [http, https].forEach((module) => { | ||
| 15 | - assert.throws(() => module[method](host, () => { | ||
| 16 | - throw new Error(`${module}.${method} should not connect to ${host}`); | ||
| 17 | - }), error); | ||
| 16 | + ['get', 'request'].forEach((fn) => { | ||
| 17 | + Object.keys(modules).forEach((module) => { | ||
| 18 | + const doNotCall = common.mustNotCall( | ||
| 19 | + `${module}.${fn} should not connect to ${host}` | ||
| 20 | + ); | ||
| 21 | + const throws = () => { modules[module][fn](host, doNotCall); }; | ||
| 22 | + common.expectsError(throws, { code: 'ERR_INVALID_DOMAIN_NAME' }); | ||
| 18 | 23 | }); | |
| 19 | 24 | }); | |
| 20 | 25 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments