添加域名时自动分割用逗号、顿号连接的域名列表

This commit is contained in:
刘祥超
2023-11-27 10:20:54 +08:00
parent 05f77f7a0d
commit 8453d754f1

View File

@@ -36,6 +36,12 @@ func (this *AddServerNamePopupAction) RunPost(params struct {
// 去除空格
serverName = regexp.MustCompile(`\s+`).ReplaceAllString(serverName, "")
// 是否包含了多个域名
var splitReg = regexp.MustCompile(`([,、|,;|])`)
if splitReg.MatchString(serverName) {
params.ServerNames = strings.Join(splitReg.Split(serverName, -1), "\n")
params.Mode = "multiple"
} else {
// 处理URL
if regexp.MustCompile(`^(?i)(http|https|ftp)://`).MatchString(serverName) {
u, err := url.Parse(serverName)
@@ -60,7 +66,13 @@ func (this *AddServerNamePopupAction) RunPost(params struct {
"name": serverName,
"type": "full",
}
} else if params.Mode == "multiple" {
this.Success()
return
}
}
if params.Mode == "multiple" {
if len(params.ServerNames) == 0 {
this.FailField("serverNames", "请输入至少域名")
}
@@ -99,8 +111,6 @@ func (this *AddServerNamePopupAction) RunPost(params struct {
"type": "full",
"subNames": serverNames,
}
} else {
this.Fail("错误的mode参数")
}
this.Success()