summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-invalid-urls.js
blob: 65cca822f9b2a5a08f752fae5b7591d9bc454c57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
'use strict';

const common = require('../common');
if (!common.hasCrypto) {
  common.skip('missing crypto');
  return;
}

const assert = require('assert');
const http = require('http');
const https = require('https');
const error = 'Unable to determine the domain name';

function test(host) {
  ['get', 'request'].forEach((method) => {
    [http, https].forEach((module) => {
      assert.throws(() => module[method](host, () => {
        throw new Error(`${module}.${method} should not connect to ${host}`);
      }), error);
    });
  });
}

['www.nodejs.org', 'localhost', '127.0.0.1', 'http://:80/'].forEach(test);