初始化访客IP配置时去除首尾可能的空格

This commit is contained in:
GoEdgeLab
2023-07-07 08:31:17 +08:00
parent c673b738d5
commit d7b8e9f179

View File

@@ -19,6 +19,7 @@ type HTTPRemoteAddrConfig struct {
// Init 初始化 // Init 初始化
func (this *HTTPRemoteAddrConfig) Init() error { func (this *HTTPRemoteAddrConfig) Init() error {
this.Value = strings.TrimSpace(this.Value)
if len(this.Value) == 0 { if len(this.Value) == 0 {
this.isEmpty = true this.isEmpty = true
} else if regexp.MustCompile(`\s+`).ReplaceAllString(this.Value, "") == "${remoteAddr}" { } else if regexp.MustCompile(`\s+`).ReplaceAllString(this.Value, "") == "${remoteAddr}" {