summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-deprecated-urls.js
blob: 5bb9f66ebe71267a1f551656a8d20624ab6d2133 (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
25
26
27
28
29
30
31
32
33
/* eslint-disable node-core/crypto-check */

'use strict';

const common = require('../common');

const http = require('http');
const modules = { http };

const deprecations = [
  ['The provided URL http://[www.nodejs.org] is not a valid URL, and is supported ' +
  'in the http module solely for compatibility.',
   'DEP0109'],
];

if (common.hasCrypto) {
  const https = require('https');
  modules.https = https;
  deprecations.push(
    ['The provided URL https://[www.nodejs.org] is not a valid URL, and is supported ' +
    'in the https module solely for compatibility.',
     'DEP0109'],
  );
}

common.expectWarning('DeprecationWarning', deprecations);

Object.keys(modules).forEach((module) => {
  const doNotCall = common.mustNotCall(
    `${module}.request should not connect to ${module}://[www.nodejs.org]`
  );
  modules[module].request(`${module}://[www.nodejs.org]`, doNotCall).abort();
});