Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit e21d38c

Browse files
committed
[proxy]去除重写规则中使用代理转发时路径中多余的斜杠
1 parent 7d8cf27 commit e21d38c

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

teaweb/actions/default/proxy/rewrite/add.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/iwind/TeaGo/actions"
1010
"github.com/iwind/TeaGo/maps"
1111
"regexp"
12+
"strings"
1213
)
1314

1415
type AddAction actions.Action
@@ -137,7 +138,7 @@ func (this *AddAction) RunPost(params struct {
137138
if params.TargetType == "url" {
138139
rewriteRule.Replace = params.Replace
139140
} else {
140-
rewriteRule.Replace = "proxy://" + params.ProxyId + params.Replace
141+
rewriteRule.Replace = "proxy://" + params.ProxyId + "/" + strings.TrimLeft(params.Replace, "/")
141142
}
142143
if len(params.RedirectMode) > 0 {
143144
rewriteRule.AddFlag(params.RedirectMode, nil)

teaweb/actions/default/proxy/rewrite/update.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/iwind/TeaGo/actions"
1010
"github.com/iwind/TeaGo/maps"
1111
"regexp"
12+
"strings"
1213
)
1314

1415
type UpdateAction actions.Action
@@ -168,7 +169,7 @@ func (this *UpdateAction) RunPost(params struct {
168169
if params.TargetType == "url" {
169170
rewriteRule.Replace = params.Replace
170171
} else {
171-
rewriteRule.Replace = "proxy://" + params.ProxyId + "/" + params.Replace
172+
rewriteRule.Replace = "proxy://" + params.ProxyId + "/" + strings.TrimLeft(params.Replace, "/")
172173
}
173174
rewriteRule.Flags = []string{}
174175
rewriteRule.FlagOptions = maps.Map{}

0 commit comments

Comments
 (0)