diff --git a/lib/internal/url.js b/lib/internal/url.js index 3ef8e272f906e7..440fc0315ed309 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -1369,11 +1369,6 @@ function toPathIfFileURL(fileURLOrPath) { return fileURLToPath(fileURLOrPath); } -function NativeURL(ctx) { - this[context] = ctx; -} -NativeURL.prototype = URL.prototype; - function constructUrl(flags, protocol, username, password, host, port, path, query, fragment) { var ctx = new URLContext(); @@ -1386,10 +1381,13 @@ function constructUrl(flags, protocol, username, password, ctx.query = query; ctx.fragment = fragment; ctx.host = host; - const url = new NativeURL(ctx); - url[searchParams] = new URLSearchParams(); - url[searchParams][context] = url; - initSearchParams(url[searchParams], query); + + const url = Object.create(URL.prototype); + url[context] = ctx; + const params = new URLSearchParams(); + url[searchParams] = params; + params[context] = url; + initSearchParams(params, query); return url; } setURLConstructor(constructUrl);