diff --git a/lib/internal/url.js b/lib/internal/url.js index 3dc317a8bbb7c3..ad3f0d6f0bbab0 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -122,6 +122,13 @@ function onParseProtocolComplete(flags, protocol, username, password, if ((s && !newIsSpecial) || (!s && newIsSpecial)) { return; } + if (protocol === 'file:' && + (ctx.username || ctx.password || ctx.port !== undefined)) { + return; + } + if (ctx.scheme === 'file:' && !ctx.host) { + return; + } if (newIsSpecial) { ctx.flags |= binding.URL_FLAGS_SPECIAL; } else {