mirror of
				https://github.com/TeaOSLab/EdgeCommon.git
				synced 2025-11-04 05:00:24 +08:00 
			
		
		
		
	URL跳转精准匹配/匹配前缀支持URL查询参数
This commit is contained in:
		@@ -55,6 +55,7 @@ type HTTPHostRedirectConfig struct {
 | 
				
			|||||||
	PortAfterScheme string   `yaml:"portAfterScheme" json:"portAfterScheme"` // 跳转之后的协议
 | 
						PortAfterScheme string   `yaml:"portAfterScheme" json:"portAfterScheme"` // 跳转之后的协议
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	beforePortRanges [][2]int // [[from, to], {from2, to2}, ...]
 | 
						beforePortRanges [][2]int // [[from, to], {from2, to2}, ...]
 | 
				
			||||||
 | 
						beforeHasQuery   bool
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Init 初始化
 | 
					// Init 初始化
 | 
				
			||||||
@@ -65,6 +66,8 @@ func (this *HTTPHostRedirectConfig) Init() error {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if this.Type == HTTPHostRedirectTypeURL {
 | 
						if this.Type == HTTPHostRedirectTypeURL {
 | 
				
			||||||
		if !this.MatchRegexp {
 | 
							if !this.MatchRegexp {
 | 
				
			||||||
 | 
								this.beforeHasQuery = strings.Contains(this.BeforeURL, "?")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			u, err := url.Parse(this.BeforeURL)
 | 
								u, err := url.Parse(this.BeforeURL)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				return err
 | 
									return err
 | 
				
			||||||
@@ -117,6 +120,11 @@ func (this *HTTPHostRedirectConfig) RealBeforeURL() string {
 | 
				
			|||||||
	return this.realBeforeURL
 | 
						return this.realBeforeURL
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// BeforeHasQuery 判断跳转前URL是否有查询参数
 | 
				
			||||||
 | 
					func (this *HTTPHostRedirectConfig) BeforeHasQuery() bool {
 | 
				
			||||||
 | 
						return this.beforeHasQuery
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// BeforeURLRegexp 跳转前URL正则表达式
 | 
					// BeforeURLRegexp 跳转前URL正则表达式
 | 
				
			||||||
func (this *HTTPHostRedirectConfig) BeforeURLRegexp() *regexp.Regexp {
 | 
					func (this *HTTPHostRedirectConfig) BeforeURLRegexp() *regexp.Regexp {
 | 
				
			||||||
	return this.beforeURLRegexp
 | 
						return this.beforeURLRegexp
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user