diff options
author | Joshua Erickson <josh@snoj.us> | 2012-10-08 19:51:59 -0500 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2012-11-28 21:51:27 +0100 |
commit | c9f2531ae02d49add0b5eb00bbad0fc05b5a8881 (patch) | |
tree | c6636d929664d35c1a7670067c1948767b6d860b /test | |
parent | 83161455bd428c8c66befdf7c882a01e6255e3af (diff) | |
download | nodejs-c9f2531ae02d49add0b5eb00bbad0fc05b5a8881.tar.gz nodejs-c9f2531ae02d49add0b5eb00bbad0fc05b5a8881.tar.bz2 nodejs-c9f2531ae02d49add0b5eb00bbad0fc05b5a8881.zip |
net: More accurate IP address validation and IPv6 dotted notation.
* Added isIP method to make use of inet_pton to cares_wrap.cc
* Modified net.isIP() to make use of new C++ isIP method.
* Added new tests to test-net-isip.js.
This is a back-port of commit fb6377e from the master branch.
Diffstat (limited to 'test')
-rw-r--r-- | test/simple/test-net-isip.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/test/simple/test-net-isip.js b/test/simple/test-net-isip.js index 4f60f5021..0d324007f 100644 --- a/test/simple/test-net-isip.js +++ b/test/simple/test-net-isip.js @@ -31,7 +31,20 @@ assert.equal(net.isIP('0000:0000:0000:0000:0000:0000:0000:0000::0000'), 0); assert.equal(net.isIP('1050:0:0:0:5:600:300c:326b'), 6); assert.equal(net.isIP('2001:252:0:1::2008:6'), 6); assert.equal(net.isIP('2001:dead:beef:1::2008:6'), 6); +assert.equal(net.isIP('2001::'), 6); +assert.equal(net.isIP('2001:dead::'), 6); +assert.equal(net.isIP('2001:dead:beef::'), 6); +assert.equal(net.isIP('2001:dead:beef:1::'), 6); assert.equal(net.isIP('ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'), 6); +assert.equal(net.isIP(':2001:252:0:1::2008:6:'), 0); +assert.equal(net.isIP(':2001:252:0:1::2008:6'), 0); +assert.equal(net.isIP('2001:252:0:1::2008:6:'), 0); +assert.equal(net.isIP('2001:252::1::2008:6'), 0); +assert.equal(net.isIP('::2001:252:1:2008:6'), 6); +assert.equal(net.isIP('::2001:252:1:1.1.1.1'), 6); +assert.equal(net.isIP('::2001:252:1:255.255.255.255'), 6); +assert.equal(net.isIP('::2001:252:1:255.255.255.255.76'), 0); +assert.equal(net.isIP('::anything'), 0); assert.equal(net.isIP('::1'), 6); assert.equal(net.isIP('::'), 6); assert.equal(net.isIP('0000:0000:0000:0000:0000:0000:12345:0000'), 0); @@ -45,4 +58,4 @@ assert.equal(net.isIPv4('2001:252:0:1::2008:6'), false); assert.equal(net.isIPv6('127.0.0.1'), false); assert.equal(net.isIPv6('example.com'), false); -assert.equal(net.isIPv6('2001:252:0:1::2008:6'), true);
\ No newline at end of file +assert.equal(net.isIPv6('2001:252:0:1::2008:6'), true); |