You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
306 B
20 lines
306 B
'use strict';
|
|
|
|
var re = /^[a-zA-Z0-9\.\-]+$/;
|
|
var punycode = require('punycode');
|
|
|
|
var utils = module.exports;
|
|
|
|
utils.isValidDomain = function (domain) {
|
|
if (re.test(domain)) {
|
|
return domain;
|
|
}
|
|
|
|
domain = punycode.toASCII(domain);
|
|
|
|
if (re.test(domain)) {
|
|
return domain;
|
|
}
|
|
|
|
return '';
|
|
};
|
|
|