Skip to content

Commit 6e2fe1c

Browse files
Trottrvagg
authored andcommittedSep 11, 2015
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: #2468 PR-URL: #2785 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent d664b95 commit 6e2fe1c

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed
 

‎test/common.js

-9
Original file line numberDiff line numberDiff line change
@@ -436,15 +436,6 @@ exports.hasMultiLocalhost = function hasMultiLocalhost() {
436436
return ret === 0;
437437
};
438438

439-
exports.isValidHostname = function(str) {
440-
// See http://stackoverflow.com/a/3824105
441-
var re = new RegExp(
442-
'^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])' +
443-
'(\\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9]))*$');
444-
445-
return !!str.match(re) && str.length <= 255;
446-
};
447-
448439
exports.fileExists = function(pathname) {
449440
try {
450441
fs.accessSync(pathname);

‎test/internet/test-dns.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,8 @@ TEST(function test_lookup_all_mixed(done) {
575575
TEST(function test_lookupservice_ip_ipv4(done) {
576576
var req = dns.lookupService('127.0.0.1', 80, function(err, host, service) {
577577
if (err) throw err;
578-
assert.ok(common.isValidHostname(host));
578+
assert.equal(typeof host, 'string');
579+
assert(host);
579580

580581
/*
581582
* Retrieve the actual HTTP service name as setup on the host currently
@@ -604,7 +605,8 @@ TEST(function test_lookupservice_ip_ipv4(done) {
604605
TEST(function test_lookupservice_ip_ipv6(done) {
605606
var req = dns.lookupService('::1', 80, function(err, host, service) {
606607
if (err) throw err;
607-
assert.ok(common.isValidHostname(host));
608+
assert.equal(typeof host, 'string');
609+
assert(host);
608610

609611
/*
610612
* Retrieve the actual HTTP service name as setup on the host currently

0 commit comments

Comments
 (0)