diff --git a/internal/web/actions/default/servers/addServerNamePopup.go b/internal/web/actions/default/servers/addServerNamePopup.go index 66e13f72..88176049 100644 --- a/internal/web/actions/default/servers/addServerNamePopup.go +++ b/internal/web/actions/default/servers/addServerNamePopup.go @@ -4,6 +4,7 @@ import ( "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/maps" + "net" "net/url" "regexp" "strings" @@ -43,6 +44,14 @@ func (this *AddServerNamePopupAction) RunPost(params struct { } } + // 去除端口 + if regexp.MustCompile(`:\d+$`).MatchString(serverName) { + host, _, err := net.SplitHostPort(serverName) + if err == nil && len(host) > 0 { + serverName = host + } + } + params.Must. Field("serverName", serverName). Require("请输入域名") @@ -72,6 +81,14 @@ func (this *AddServerNamePopupAction) RunPost(params struct { } } + // 去除端口 + if regexp.MustCompile(`:\d+$`).MatchString(serverName) { + host, _, err := net.SplitHostPort(serverName) + if err == nil && len(host) > 0 { + serverName = host + } + } + // 转成小写 serverName = strings.ToLower(serverName)