mirror of
https://github.com/nodejs/node.git
synced 2025-04-30 15:41:06 +00:00

This switches the url parser from `url.parse()` to the WHATWG URL parser while keeping `url.parse()` as fallback. Also add tests for invalid url deprecations and correct hostname checks. PR-URL: https://github.com/nodejs/node/pull/20270 Fixes: https://github.com/nodejs/node/issues/19468 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
29 lines
745 B
JavaScript
29 lines
745 B
JavaScript
/* eslint-disable node-core/crypto-check */
|
|
// Flags: --expose-internals
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
const { outHeadersKey } = require('internal/http');
|
|
|
|
const http = require('http');
|
|
const modules = { http };
|
|
|
|
if (common.hasCrypto) {
|
|
const https = require('https');
|
|
modules.https = https;
|
|
}
|
|
|
|
Object.keys(modules).forEach((module) => {
|
|
const doNotCall = common.mustNotCall(
|
|
`${module}.request should not connect to ${module}://example.com%60x.example.com`
|
|
);
|
|
const req = modules[module].request(`${module}://example.com%60x.example.com`, doNotCall);
|
|
assert.deepStrictEqual(req[outHeadersKey].host, [
|
|
'Host',
|
|
'example.com`x.example.com',
|
|
]);
|
|
req.abort();
|
|
});
|