diff options
author | Alexis Campailla <alexis@janeasystems.com> | 2014-08-12 16:48:02 +0200 |
---|---|---|
committer | Timothy J Fontaine <tjfontaine@gmail.com> | 2014-08-13 11:44:20 -0700 |
commit | 0d357fa135dedaae644d73b0b9a907b90c66f200 (patch) | |
tree | 606729f57a27ad02f096cf7e15abbea01f2ffd91 /test/common.js | |
parent | 0565d52a71313ca1334fa89f11cb626e4bc2b522 (diff) | |
download | nodejs-0d357fa135dedaae644d73b0b9a907b90c66f200.tar.gz nodejs-0d357fa135dedaae644d73b0b9a907b90c66f200.tar.bz2 nodejs-0d357fa135dedaae644d73b0b9a907b90c66f200.zip |
test: fix dns test
Fix a few issues in test/internet/test-dns.js:
- 'hint' should be 'hints'
- reverse name lookup is not guaranteed to return 'localhost'
- V4MAPPED hint requires IPV6 address family
Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
Diffstat (limited to 'test/common.js')
-rw-r--r-- | test/common.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/common.js b/test/common.js index b83d98144..bd7318c95 100644 --- a/test/common.js +++ b/test/common.js @@ -289,3 +289,12 @@ exports.getServiceName = function getServiceName(port, protocol) { return serviceName; } + +exports.isValidHostname = function(str) { + // See http://stackoverflow.com/a/3824105 + var re = new RegExp( + '^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])' + + '(\\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9]))*$'); + + return !!str.match(re) && str.length <= 255; +} |