From d6fbebda54e2f8d18ad74e46f8e16b87f2e88187 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Sun, 5 Feb 2023 10:22:54 -0500 Subject: [PATCH] url: remove unused `setURLConstructor` function PR-URL: https://github.com/nodejs/node/pull/46485 Reviewed-By: Luigi Pinca Reviewed-By: Zeyu "Alex" Yang Reviewed-By: Robert Nagy Reviewed-By: James M Snell --- lib/internal/url.js | 24 ------------------------ src/node_url.cc | 9 --------- 2 files changed, 33 deletions(-) diff --git a/lib/internal/url.js b/lib/internal/url.js index 8aca33b68f61ec..f300a3c8a89b16 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -92,7 +92,6 @@ const { domainToUnicode: _domainToUnicode, encodeAuth, parse, - setURLConstructor, URL_FLAGS_CANNOT_BE_BASE, URL_FLAGS_HAS_FRAGMENT, URL_FLAGS_HAS_HOST, @@ -1572,29 +1571,6 @@ function toPathIfFileURL(fileURLOrPath) { return fileURLToPath(fileURLOrPath); } -function constructUrl(flags, protocol, username, password, - host, port, path, query, fragment) { - const ctx = new URLContext(); - ctx.flags = flags; - ctx.scheme = protocol; - ctx.username = (flags & URL_FLAGS_HAS_USERNAME) !== 0 ? username : ''; - ctx.password = (flags & URL_FLAGS_HAS_PASSWORD) !== 0 ? password : ''; - ctx.port = port; - ctx.path = (flags & URL_FLAGS_HAS_PATH) !== 0 ? path : []; - ctx.query = query; - ctx.fragment = fragment; - ctx.host = host; - - const url = { __proto__: URL.prototype }; - url[context] = ctx; - const params = new URLSearchParams(); - url[searchParams] = params; - params[context] = url; - initSearchParams(params, query); - return url; -} -setURLConstructor(constructUrl); - module.exports = { toUSVString, fileURLToPath, diff --git a/src/node_url.cc b/src/node_url.cc index b8edc0c21d7e5b..14c9d828f740a0 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -1824,13 +1824,6 @@ void DomainToUnicode(const FunctionCallbackInfo& args) { String::NewFromUtf8(env->isolate(), out.c_str()).ToLocalChecked()); } -void SetURLConstructor(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args); - CHECK_EQ(args.Length(), 1); - CHECK(args[0]->IsFunction()); - env->set_url_constructor_function(args[0].As()); -} - void Initialize(Local target, Local unused, Local context, @@ -1839,7 +1832,6 @@ void Initialize(Local target, SetMethodNoSideEffect(context, target, "encodeAuth", EncodeAuthSet); SetMethodNoSideEffect(context, target, "domainToASCII", DomainToASCII); SetMethodNoSideEffect(context, target, "domainToUnicode", DomainToUnicode); - SetMethod(context, target, "setURLConstructor", SetURLConstructor); #define XX(name, _) NODE_DEFINE_CONSTANT(target, name); FLAGS(XX) @@ -1856,7 +1848,6 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) { registry->Register(EncodeAuthSet); registry->Register(DomainToASCII); registry->Register(DomainToUnicode); - registry->Register(SetURLConstructor); } std::string URL::ToFilePath() const {