mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-12-14 11:40:24 +08:00
添加域名时移除多余的端口号
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"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.
|
params.Must.
|
||||||
Field("serverName", serverName).
|
Field("serverName", serverName).
|
||||||
Require("请输入域名")
|
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)
|
serverName = strings.ToLower(serverName)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user