mirror of
https://github.com/certd/certd.git
synced 2026-07-29 08:37:36 +08:00
fix: 允许七牛云cdn插件输入.号开头的通配符域名
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import Validator from "async-validator";
|
||||
// 自定义验证器函数
|
||||
function isDomain(rule, value) {
|
||||
export function isDomain(rule: any, value: any) {
|
||||
if (value == null) {
|
||||
return true;
|
||||
}
|
||||
@@ -8,9 +8,14 @@ function isDomain(rule, value) {
|
||||
if (typeof value === "string") {
|
||||
domains = value.split(",");
|
||||
}
|
||||
|
||||
const allowDotStart = rule.allowDotStart ? "\\.|" : "";
|
||||
const exp = `^(?:${allowDotStart}\\*\\.|[0-9a-zA-Z\u4e00-\u9fa5-]+\\.)+[0-9a-zA-Z\u4e00-\u9fa5-]+$`;
|
||||
const compiled = new RegExp(exp);
|
||||
for (const domain of domains) {
|
||||
//域名可以是泛域名,中文域名,数字域名,英文域名,域名中可以包含-和. ,可以_开头
|
||||
if (!/^(?:\*\.|[0-9a-zA-Z\u4e00-\u9fa5-]+\.)+[0-9a-zA-Z\u4e00-\u9fa5-]+$/.test(domain)) {
|
||||
|
||||
if (!compiled.test(domain)) {
|
||||
throw new Error(`域名有误:${domain},请输入正确的域名`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user