mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-10 01:10:27 +08:00
修复重写规则中没有匹配条件就无法生效的问题
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user