mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2026-01-26 02:55:47 +08:00
缓存条件类型增加“URL通配符”
This commit is contained in:
@@ -3,7 +3,6 @@ package shared
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/iwind/TeaGo/Tea"
|
||||
"github.com/iwind/TeaGo/assert"
|
||||
"net"
|
||||
"regexp"
|
||||
@@ -85,6 +84,78 @@ func TestRequestCond_Compare1(t *testing.T) {
|
||||
}))
|
||||
}
|
||||
|
||||
{
|
||||
var cond = HTTPRequestCond{
|
||||
Param: "/hello",
|
||||
Operator: RequestCondOperatorWildcardMatch,
|
||||
Value: "/*",
|
||||
}
|
||||
a.IsNil(cond.Init())
|
||||
a.IsTrue(cond.Match(func(format string) string {
|
||||
return format
|
||||
}))
|
||||
}
|
||||
|
||||
{
|
||||
var cond = HTTPRequestCond{
|
||||
Param: "/hello/world",
|
||||
Operator: RequestCondOperatorWildcardMatch,
|
||||
Value: "/*/world",
|
||||
}
|
||||
a.IsNil(cond.Init())
|
||||
a.IsTrue(cond.Match(func(format string) string {
|
||||
return format
|
||||
}))
|
||||
}
|
||||
|
||||
{
|
||||
var cond = HTTPRequestCond{
|
||||
Param: "/hello/world",
|
||||
Operator: RequestCondOperatorWildcardMatch,
|
||||
Value: "/H*/world",
|
||||
}
|
||||
a.IsNil(cond.Init())
|
||||
a.IsTrue(cond.Match(func(format string) string {
|
||||
return format
|
||||
}))
|
||||
}
|
||||
|
||||
{
|
||||
var cond = HTTPRequestCond{
|
||||
Param: "/hello",
|
||||
Operator: RequestCondOperatorWildcardMatch,
|
||||
Value: "/hello/*",
|
||||
}
|
||||
a.IsNil(cond.Init())
|
||||
a.IsFalse(cond.Match(func(format string) string {
|
||||
return format
|
||||
}))
|
||||
}
|
||||
|
||||
{
|
||||
var cond = HTTPRequestCond{
|
||||
Param: "/hello/world",
|
||||
Operator: RequestCondOperatorWildcardNotMatch,
|
||||
Value: "/hello/*",
|
||||
}
|
||||
a.IsNil(cond.Init())
|
||||
a.IsFalse(cond.Match(func(format string) string {
|
||||
return format
|
||||
}))
|
||||
}
|
||||
|
||||
{
|
||||
var cond = HTTPRequestCond{
|
||||
Param: "/hello",
|
||||
Operator: RequestCondOperatorWildcardNotMatch,
|
||||
Value: "/hello/*",
|
||||
}
|
||||
a.IsNil(cond.Init())
|
||||
a.IsTrue(cond.Match(func(format string) string {
|
||||
return format
|
||||
}))
|
||||
}
|
||||
|
||||
{
|
||||
cond := HTTPRequestCond{
|
||||
Param: "123.123",
|
||||
@@ -687,7 +758,7 @@ func TestRequestCond_File(t *testing.T) {
|
||||
}))
|
||||
}
|
||||
|
||||
{
|
||||
/**{
|
||||
cond := HTTPRequestCond{
|
||||
Param: "a.png",
|
||||
Operator: RequestCondOperatorFileExist,
|
||||
@@ -762,7 +833,7 @@ func TestRequestCond_File(t *testing.T) {
|
||||
a.IsFalse(cond.Match(func(source string) string {
|
||||
return source
|
||||
}))
|
||||
}
|
||||
}**/
|
||||
}
|
||||
|
||||
func TestRequestCond_MimeType(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user