mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
lib: enforce use of URLParse
There's no reason to use the user-mutable `URL.parse` in core. PR-URL: https://github.com/nodejs/node/pull/61016 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: René <contact.9a5d6388@renegade334.me.uk> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Erick Wendel <erick.workspace@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
@@ -30,6 +30,10 @@ const noRestrictedSyntax = [
|
||||
selector: "CallExpression[callee.object.name='Error'][callee.property.name='captureStackTrace']",
|
||||
message: "Use 'hideStackFrames' from 'internal/errors' instead.",
|
||||
},
|
||||
{
|
||||
selector: "CallExpression[callee.object.name='URL'][callee.property.name='parse']",
|
||||
message: "Use 'URLParse' from 'internal/url' instead.",
|
||||
},
|
||||
{
|
||||
selector: "AssignmentExpression:matches([left.object.name='Error']):matches([left.name='prepareStackTrace'], [left.property.name='prepareStackTrace'])",
|
||||
message: "Use 'overrideStackTrace' from 'internal/errors' instead.",
|
||||
|
||||
@@ -37,7 +37,7 @@ const {
|
||||
kDeserialize,
|
||||
} = require('internal/worker/js_transferable');
|
||||
|
||||
const { URL } = require('internal/url');
|
||||
const { URLParse } = require('internal/url');
|
||||
|
||||
const kHandle = Symbol('kHandle');
|
||||
const kDetail = Symbol('kDetail');
|
||||
@@ -156,7 +156,7 @@ class SocketAddress {
|
||||
const {
|
||||
hostname: address,
|
||||
port,
|
||||
} = URL.parse(`http://${input}`);
|
||||
} = URLParse(`http://${input}`);
|
||||
if (address.startsWith('[') && address.endsWith(']')) {
|
||||
return new SocketAddress({
|
||||
address: address.slice(1, -1),
|
||||
|
||||
@@ -30,7 +30,7 @@ const {
|
||||
fileURLToPath,
|
||||
isURL,
|
||||
pathToFileURL,
|
||||
URL,
|
||||
URLParse,
|
||||
} = require('internal/url');
|
||||
const {
|
||||
emitExperimentalWarning,
|
||||
@@ -652,7 +652,7 @@ class MockTracker {
|
||||
if (format) { // Format is not yet known for ambiguous files when detection is enabled.
|
||||
validateOneOf(format, 'format', kSupportedFormats);
|
||||
}
|
||||
const baseURL = URL.parse(url);
|
||||
const baseURL = URLParse(url);
|
||||
|
||||
if (!baseURL) {
|
||||
throw new ERR_INVALID_ARG_VALUE(
|
||||
|
||||
Reference in New Issue
Block a user