mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 18:29:01 +00:00

isLegalPort can be used in more places than just net.js. This change moves it to a new internal net module in preparation for using it in the dns module. PR-URL: https://github.com/nodejs/node/pull/4882 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
16 lines
488 B
JavaScript
16 lines
488 B
JavaScript
'use strict';
|
|
|
|
// Flags: --expose-internals
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const net = require('internal/net');
|
|
|
|
assert.strictEqual(net.isLegalPort(''), false);
|
|
assert.strictEqual(net.isLegalPort('0'), true);
|
|
assert.strictEqual(net.isLegalPort(0), true);
|
|
assert.strictEqual(net.isLegalPort(65536), false);
|
|
assert.strictEqual(net.isLegalPort('65535'), true);
|
|
assert.strictEqual(net.isLegalPort(undefined), false);
|
|
assert.strictEqual(net.isLegalPort(null), true);
|