The added validation allows non-negative numbers and numeric strings. All other values result in a thrown exception. Fixes: https://github.com/joyent/node/issues/9194 PR-URL: https://github.com/joyent/node/pull/9268 Reviewed-By: Julien Gilli <julien.gilli@joyent.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: James M Snell <jasnell@users.noreply.github.com>
21 lines
450 B
JavaScript
21 lines
450 B
JavaScript
var common = require('../common');
|
|
var assert = require('assert');
|
|
var net = require('net');
|
|
|
|
connect({
|
|
host: 'localhost',
|
|
port: common.PORT,
|
|
localPort: 'foobar',
|
|
}, 'localPort should be a number: foobar');
|
|
|
|
connect({
|
|
host: 'localhost',
|
|
port: common.PORT,
|
|
localAddress: 'foobar',
|
|
}, 'localAddress should be a valid IP: foobar');
|
|
|
|
function connect(opts, msg) {
|
|
assert.throws(function() {
|
|
var client = net.connect(opts);
|
|
}, msg);
|
|
}
|