Skip to content

Commit 540929d

Browse files
TimothyGuBridgeAR
authored andcommitted
url: simplify native URL object construction
Co-authored-by: Joyee Cheung <[email protected]> PR-URL: #24495 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Daijiro Wachi <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 0d7ee19 commit 540929d

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

lib/internal/url.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -1369,11 +1369,6 @@ function toPathIfFileURL(fileURLOrPath) {
13691369
return fileURLToPath(fileURLOrPath);
13701370
}
13711371

1372-
function NativeURL(ctx) {
1373-
this[context] = ctx;
1374-
}
1375-
NativeURL.prototype = URL.prototype;
1376-
13771372
function constructUrl(flags, protocol, username, password,
13781373
host, port, path, query, fragment) {
13791374
var ctx = new URLContext();
@@ -1386,10 +1381,13 @@ function constructUrl(flags, protocol, username, password,
13861381
ctx.query = query;
13871382
ctx.fragment = fragment;
13881383
ctx.host = host;
1389-
const url = new NativeURL(ctx);
1390-
url[searchParams] = new URLSearchParams();
1391-
url[searchParams][context] = url;
1392-
initSearchParams(url[searchParams], query);
1384+
1385+
const url = Object.create(URL.prototype);
1386+
url[context] = ctx;
1387+
const params = new URLSearchParams();
1388+
url[searchParams] = params;
1389+
params[context] = url;
1390+
initSearchParams(params, query);
13931391
return url;
13941392
}
13951393
setURLConstructor(constructUrl);

0 commit comments

Comments
 (0)