From 2bc070455e9e760da4da488e61120ffba8a55b36 Mon Sep 17 00:00:00 2001 From: Sergey Golovin Date: Thu, 8 Mar 2018 15:30:46 +0300 Subject: [PATCH] url: use existing handlers instead of duplicated code --- lib/internal/url.js | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/lib/internal/url.js b/lib/internal/url.js index 842d26c4aac9b6..53586e9535f6b5 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -248,20 +248,6 @@ function onParseProtocolComplete(flags, protocol, username, password, 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, host, port, path, query, fragment) { const ctx = this[context]; @@ -279,6 +265,13 @@ function onParsePortComplete(flags, protocol, username, password, 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, host, port, path, query, fragment) { const ctx = this[context];