lib: fix validateport error message when allowZero is false

PR-URL: https://github.com/nodejs/node/pull/32861
Fixes: https://github.com/nodejs/node/issues/32857
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
rickyes 2020-04-15 13:23:26 +08:00 committed by Anna Henningsen
parent aa9708e479
commit 1d0b24924f
No known key found for this signature in database
GPG key ID: A94130F0BFC8EBE9
3 changed files with 8 additions and 4 deletions

View file

@ -190,7 +190,7 @@ function validatePort(port, name = 'Port', { allowZero = true } = {}) {
+port !== (+port >>> 0) ||
port > 0xFFFF ||
(port === 0 && !allowZero)) {
throw new ERR_SOCKET_BAD_PORT(name, port);
throw new ERR_SOCKET_BAD_PORT(name, port, allowZero);
}
return port | 0;
}