修复重写规则中没有匹配条件就无法生效的问题

This commit is contained in:
GoEdgeLab
2021-06-19 20:52:54 +08:00
parent 27c0a6f334
commit ef17c857b1
3 changed files with 3 additions and 3 deletions

View File

@@ -65,7 +65,7 @@ func (this *HTTPHostRedirectConfig) BeforeURLRegexp() *regexp.Regexp {
// MatchRequest 判断请求是否符合条件 // MatchRequest 判断请求是否符合条件
func (this *HTTPHostRedirectConfig) MatchRequest(formatter func(source string) string) bool { func (this *HTTPHostRedirectConfig) MatchRequest(formatter func(source string) string) bool {
if this.Conds == nil { if this.Conds == nil || !this.Conds.HasRequestConds() {
return true return true
} }
return this.Conds.MatchRequest(formatter) return this.Conds.MatchRequest(formatter)

View File

@@ -260,7 +260,7 @@ func (this *HTTPLocationConfig) ExtractPattern() error {
// TODO 支持子Location // TODO 支持子Location
func (this *HTTPLocationConfig) Match(path string, formatter func(source string) string) (vars map[string]string, isMatched bool) { 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 return
} }

View File

@@ -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 return "", nil, false
} }