optimize rewrite regex (#801)

This commit is contained in:
澄潭
2024-01-25 10:20:49 +08:00
committed by GitHub
parent 90f89cf588
commit 073c10df77
2 changed files with 10 additions and 1 deletions

View File

@@ -83,7 +83,7 @@ func (i *Ingress) NeedRegexMatch(path string) bool {
if i.Rewrite == nil {
return false
}
if strings.ContainsAny(path, `\.+*?()|[]{}^$`) {
if i.Rewrite.RewriteTarget != "" && strings.ContainsAny(path, `\.+*?()|[]{}^$`) {
return true
}
if strings.ContainsAny(i.Rewrite.RewriteTarget, `$\`) {

View File

@@ -67,6 +67,15 @@ func TestNeedRegexMatch(t *testing.T) {
inputPath: "/.*",
expect: true,
},
{
input: &Ingress{
Rewrite: &RewriteConfig{
UseRegex: false,
},
},
inputPath: "/.",
expect: false,
},
{
input: &Ingress{
Rewrite: &RewriteConfig{