| 102 | } |
| 103 | |
| 104 | func Test_CORS_AllowOrigins_NormalizedExactLookup(t *testing.T) { |
| 105 | t.Parallel() |
| 106 | |
| 107 | app := fiber.New() |
| 108 | app.Use(New(Config{AllowOrigins: []string{" HTTP://EXAMPLE.COM/ "}})) |
| 109 | |
| 110 | origin := "http://example.com" |
| 111 | |
| 112 | ctx := &fasthttp.RequestCtx{} |
| 113 | ctx.Request.Header.SetMethod(fiber.MethodOptions) |
| 114 | ctx.Request.Header.Set(fiber.HeaderAccessControlRequestMethod, fiber.MethodGet) |
| 115 | ctx.Request.Header.Set(fiber.HeaderOrigin, origin) |
| 116 | app.Handler()(ctx) |
| 117 | |
| 118 | require.Equal(t, origin, string(ctx.Response.Header.Peek(fiber.HeaderAccessControlAllowOrigin))) |
| 119 | } |
| 120 | |
| 121 | func testDefaultOrEmptyConfig(t *testing.T, app *fiber.App) { |
| 122 | t.Helper() |