mirror of
https://github.com/labstack/echo.git
synced 2025-11-27 22:38:25 +02:00
CORS middleware should compile allowOrigin regexp at creation.
This commit is contained in:
@@ -31,6 +31,18 @@ func TestCORS(t *testing.T) {
|
||||
name: "ok, wildcard AllowedOrigin with no Origin header in request",
|
||||
notExpectHeaders: map[string]string{echo.HeaderAccessControlAllowOrigin: ""},
|
||||
},
|
||||
{
|
||||
name: "ok, invalid pattern is ignored",
|
||||
givenMW: CORSWithConfig(CORSConfig{
|
||||
AllowOrigins: []string{
|
||||
"\xff", // Invalid UTF-8 makes regexp.Compile to error
|
||||
"*.example.com",
|
||||
},
|
||||
}),
|
||||
whenMethod: http.MethodOptions,
|
||||
whenHeaders: map[string]string{echo.HeaderOrigin: "http://aaa.example.com"},
|
||||
expectHeaders: map[string]string{echo.HeaderAccessControlAllowOrigin: "http://aaa.example.com"},
|
||||
},
|
||||
{
|
||||
name: "ok, specific AllowOrigins and AllowCredentials",
|
||||
givenMW: CORSWithConfig(CORSConfig{
|
||||
|
||||
Reference in New Issue
Block a user