From a9dd5e3ba33b59349a0f4e91335aadf76be6ff82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Sat, 27 May 2023 21:00:34 +0800 Subject: [PATCH] =?UTF-8?q?URL=E8=B7=B3=E8=BD=AC=E7=B2=BE=E5=87=86?= =?UTF-8?q?=E5=8C=B9=E9=85=8D/=E5=8C=B9=E9=85=8D=E5=89=8D=E7=BC=80?= =?UTF-8?q?=E6=94=AF=E6=8C=81URL=E6=9F=A5=E8=AF=A2=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/serverconfigs/http_host_redirect_config.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/serverconfigs/http_host_redirect_config.go b/pkg/serverconfigs/http_host_redirect_config.go index 6c08a65..e8c1733 100644 --- a/pkg/serverconfigs/http_host_redirect_config.go +++ b/pkg/serverconfigs/http_host_redirect_config.go @@ -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