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