From ef17c857b11a04e6017f0c4c12f5a2264c6586e1 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Sat, 19 Jun 2021 20:52:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=87=8D=E5=86=99=E8=A7=84?= =?UTF-8?q?=E5=88=99=E4=B8=AD=E6=B2=A1=E6=9C=89=E5=8C=B9=E9=85=8D=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E5=B0=B1=E6=97=A0=E6=B3=95=E7=94=9F=E6=95=88=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/serverconfigs/http_host_redirect_config.go | 2 +- pkg/serverconfigs/http_location_config.go | 2 +- pkg/serverconfigs/http_rewrite_rule.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/serverconfigs/http_host_redirect_config.go b/pkg/serverconfigs/http_host_redirect_config.go index 379ff17..a1f2e73 100644 --- a/pkg/serverconfigs/http_host_redirect_config.go +++ b/pkg/serverconfigs/http_host_redirect_config.go @@ -65,7 +65,7 @@ func (this *HTTPHostRedirectConfig) BeforeURLRegexp() *regexp.Regexp { // MatchRequest 判断请求是否符合条件 func (this *HTTPHostRedirectConfig) MatchRequest(formatter func(source string) string) bool { - if this.Conds == nil { + if this.Conds == nil || !this.Conds.HasRequestConds() { return true } return this.Conds.MatchRequest(formatter) diff --git a/pkg/serverconfigs/http_location_config.go b/pkg/serverconfigs/http_location_config.go index 46985ec..487b1b5 100644 --- a/pkg/serverconfigs/http_location_config.go +++ b/pkg/serverconfigs/http_location_config.go @@ -260,7 +260,7 @@ func (this *HTTPLocationConfig) ExtractPattern() error { // TODO 支持子Location func (this *HTTPLocationConfig) Match(path string, formatter func(source string) string) (vars map[string]string, isMatched bool) { // 判断条件 - if this.Conds != nil && !this.Conds.MatchRequest(formatter) { + if this.Conds != nil && this.Conds.HasRequestConds() && !this.Conds.MatchRequest(formatter) { return } diff --git a/pkg/serverconfigs/http_rewrite_rule.go b/pkg/serverconfigs/http_rewrite_rule.go index fe4910f..90f0788 100644 --- a/pkg/serverconfigs/http_rewrite_rule.go +++ b/pkg/serverconfigs/http_rewrite_rule.go @@ -90,7 +90,7 @@ func (this *HTTPRewriteRule) MatchRequest(requestPath string, formatter func(sou } // 判断条件 - if this.Conds != nil && !this.Conds.MatchRequest(formatter) { + if this.Conds != nil && this.Conds.HasRequestConds() && !this.Conds.MatchRequest(formatter) { return "", nil, false }