(t *testing.T)
| 614 | } |
| 615 | |
| 616 | func Test_Route_Match_UnescapedPath(t *testing.T) { |
| 617 | t.Parallel() |
| 618 | |
| 619 | app := New(Config{UnescapePath: true}) |
| 620 | |
| 621 | app.Use("/créer", func(c Ctx) error { |
| 622 | return c.SendString("test") |
| 623 | }) |
| 624 | |
| 625 | resp, err := app.Test(httptest.NewRequest(MethodGet, "/cr%C3%A9er", http.NoBody)) |
| 626 | require.NoError(t, err, "app.Test(req)") |
| 627 | require.Equal(t, StatusOK, resp.StatusCode, "Status code") |
| 628 | |
| 629 | body, err := io.ReadAll(resp.Body) |
| 630 | require.NoError(t, err, "app.Test(req)") |
| 631 | require.Equal(t, "test", app.toString(body)) |
| 632 | // without special chars |
| 633 | resp, err = app.Test(httptest.NewRequest(MethodGet, "/créer", http.NoBody)) |
| 634 | require.NoError(t, err, "app.Test(req)") |
| 635 | require.Equal(t, StatusOK, resp.StatusCode, "Status code") |
| 636 | |
| 637 | // check deactivated behavior |
| 638 | app.config.UnescapePath = false |
| 639 | resp, err = app.Test(httptest.NewRequest(MethodGet, "/cr%C3%A9er", http.NoBody)) |
| 640 | require.NoError(t, err, "app.Test(req)") |
| 641 | require.Equal(t, StatusNotFound, resp.StatusCode, "Status code") |
| 642 | } |
| 643 | |
| 644 | func Test_Route_Match_WithEscapeChar(t *testing.T) { |
| 645 | t.Parallel() |
nothing calls this directly
no test coverage detected