mirror of
https://github.com/alibaba/higress.git
synced 2026-05-08 04:17:27 +08:00
more compatiable with nginx's rewrite (#636)
This commit is contained in:
@@ -18,8 +18,9 @@ import "testing"
|
||||
|
||||
func TestNeedRegexMatch(t *testing.T) {
|
||||
testCases := []struct {
|
||||
input *Ingress
|
||||
expect bool
|
||||
input *Ingress
|
||||
inputPath string
|
||||
expect bool
|
||||
}{
|
||||
{
|
||||
input: &Ingress{},
|
||||
@@ -47,12 +48,41 @@ func TestNeedRegexMatch(t *testing.T) {
|
||||
},
|
||||
expect: false,
|
||||
},
|
||||
{
|
||||
input: &Ingress{
|
||||
Rewrite: &RewriteConfig{
|
||||
UseRegex: false,
|
||||
RewriteTarget: "/$1",
|
||||
},
|
||||
},
|
||||
expect: true,
|
||||
},
|
||||
{
|
||||
input: &Ingress{
|
||||
Rewrite: &RewriteConfig{
|
||||
UseRegex: false,
|
||||
RewriteTarget: "/",
|
||||
},
|
||||
},
|
||||
inputPath: "/.*",
|
||||
expect: true,
|
||||
},
|
||||
{
|
||||
input: &Ingress{
|
||||
Rewrite: &RewriteConfig{
|
||||
UseRegex: false,
|
||||
RewriteTarget: "/",
|
||||
},
|
||||
},
|
||||
inputPath: "/",
|
||||
expect: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
t.Run("", func(t *testing.T) {
|
||||
if testCase.input.NeedRegexMatch() != testCase.expect {
|
||||
t.Fatalf("Should be %t, but actual is %t", testCase.expect, testCase.input.NeedRegexMatch())
|
||||
if testCase.input.NeedRegexMatch(testCase.inputPath) != testCase.expect {
|
||||
t.Fatalf("Should be %t, but actual is %t", testCase.expect, !testCase.expect)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user