修正js中正则判断域名不支持二级域名的问题。

feature/assist-websocket
Apex Liu 2022-05-20 13:27:17 +08:00
parent 63845c92a8
commit 828255be6e
1 changed files with 3 additions and 2 deletions

View File

@ -48,12 +48,13 @@ function tp_is_email(email) {
} }
function tp_is_ip(ip) { function tp_is_ip(ip) {
let re = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/ let re = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
return re.test(ip); return re.test(ip);
} }
function tp_is_domain(domain) { function tp_is_domain(domain) {
let re = /^[a-zA-Z0-9\-]+\.[a-zA-Z]+$/ // let re = /^[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:\d+)*(\/\w+\.\w+)*$/;
let re = /^[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$/;
return re.test(domain); return re.test(domain);
} }