Skip to content

Commit c0423cf

Browse files
TimothyGuBethGriggs
authored andcommitted
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 d06ea3e commit c0423cf

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

‎lib/internal/url.js‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,11 +1369,6 @@ function toPathIfFileURL(fileURLOrPath) {
13691369
returnfileURLToPath(fileURLOrPath);
13701370
}
13711371

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

0 commit comments

Comments
 (0)