From 1dad19ba81983c6e22b6c453f78806962b3c31b4 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 9 Sep 2015 14:50:19 -0700 Subject: [PATCH] test: remove valid hostname check in test-dns.js Operating systems can and do return invalid hostnames if that's what they have (for example) in /etc/hosts. Test passes if no error is thrown and the hostname string is not empty. Fixes: https://github.com/nodejs/node/issues/2468 PR-URL: https://github.com/nodejs/node/pull/2785 Reviewed-By: Ben Noordhuis --- test/common.js | 9 --------- test/internet/test-dns.js | 6 ++++-- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/test/common.js b/test/common.js index 1ad66cff0b4857..9d6b4abc8b0bab 100644 --- a/test/common.js +++ b/test/common.js @@ -436,15 +436,6 @@ exports.hasMultiLocalhost = function hasMultiLocalhost() { return ret === 0; }; -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; -}; - exports.fileExists = function(pathname) { try { fs.accessSync(pathname); diff --git a/test/internet/test-dns.js b/test/internet/test-dns.js index 1059a3239e967c..c3a9e03753d133 100644 --- a/test/internet/test-dns.js +++ b/test/internet/test-dns.js @@ -575,7 +575,8 @@ TEST(function test_lookup_all_mixed(done) { TEST(function test_lookupservice_ip_ipv4(done) { var req = dns.lookupService('127.0.0.1', 80, function(err, host, service) { if (err) throw err; - assert.ok(common.isValidHostname(host)); + assert.equal(typeof host, 'string'); + assert(host); /* * Retrieve the actual HTTP service name as setup on the host currently @@ -604,7 +605,8 @@ TEST(function test_lookupservice_ip_ipv4(done) { TEST(function test_lookupservice_ip_ipv6(done) { var req = dns.lookupService('::1', 80, function(err, host, service) { if (err) throw err; - assert.ok(common.isValidHostname(host)); + assert.equal(typeof host, 'string'); + assert(host); /* * Retrieve the actual HTTP service name as setup on the host currently