url: use existing handlers instead of duplicated code
PR-URL: https://github.com/nodejs/node/pull/19267 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
b34a1e1785
commit
a892d9a0c1
@ -256,20 +256,6 @@ function onParseProtocolComplete(flags, protocol, username, password,
|
|||||||
ctx.port = port;
|
ctx.port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onParseHostComplete(flags, protocol, username, password,
|
|
||||||
host, port, path, query, fragment) {
|
|
||||||
const ctx = this[context];
|
|
||||||
if ((flags & URL_FLAGS_HAS_HOST) !== 0) {
|
|
||||||
ctx.host = host;
|
|
||||||
ctx.flags |= URL_FLAGS_HAS_HOST;
|
|
||||||
} else {
|
|
||||||
ctx.host = null;
|
|
||||||
ctx.flags &= ~URL_FLAGS_HAS_HOST;
|
|
||||||
}
|
|
||||||
if (port !== null)
|
|
||||||
ctx.port = port;
|
|
||||||
}
|
|
||||||
|
|
||||||
function onParseHostnameComplete(flags, protocol, username, password,
|
function onParseHostnameComplete(flags, protocol, username, password,
|
||||||
host, port, path, query, fragment) {
|
host, port, path, query, fragment) {
|
||||||
const ctx = this[context];
|
const ctx = this[context];
|
||||||
@ -287,6 +273,13 @@ function onParsePortComplete(flags, protocol, username, password,
|
|||||||
this[context].port = port;
|
this[context].port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onParseHostComplete(flags, protocol, username, password,
|
||||||
|
host, port, path, query, fragment) {
|
||||||
|
onParseHostnameComplete.apply(this, arguments);
|
||||||
|
if (port !== null)
|
||||||
|
onParsePortComplete.apply(this, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
function onParsePathComplete(flags, protocol, username, password,
|
function onParsePathComplete(flags, protocol, username, password,
|
||||||
host, port, path, query, fragment) {
|
host, port, path, query, fragment) {
|
||||||
const ctx = this[context];
|
const ctx = this[context];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user