mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
node: sync test-net-connect-options-invalid.js (#20607)
This commit is contained in:
@@ -1514,6 +1514,8 @@ function lookupAndConnect(self, options) {
|
||||
const host = options.host || "localhost";
|
||||
let { port, autoSelectFamilyAttemptTimeout, autoSelectFamily } = options;
|
||||
|
||||
validateString(host, "options.host");
|
||||
|
||||
if (localAddress && !isIP(localAddress)) {
|
||||
throw $ERR_INVALID_IP_ADDRESS(localAddress);
|
||||
}
|
||||
|
||||
@@ -25,3 +25,16 @@ const net = require('net');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
assert.throws(() => {
|
||||
net.createConnection({
|
||||
host: ['192.168.0.1'],
|
||||
port: 8080,
|
||||
});
|
||||
}, {
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
name: 'TypeError',
|
||||
message: 'The "options.host" property must be of type string. Received an instance of Array',
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user