Skip to content

Commit 540929d

Browse files
TimothyGuBridgeAR
authored andcommittedDec 5, 2018
url: simplify native URL object construction
Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com> PR-URL: #24495 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
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)