MCPcopy
hub / github.com/gofiber/fiber / Test_Route_Match_UnescapedPath

Function Test_Route_Match_UnescapedPath

router_test.go:616–642  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

614}
615
616func 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
644func Test_Route_Match_WithEscapeChar(t *testing.T) {
645 t.Parallel()

Callers

nothing calls this directly

Calls 5

TestMethod · 0.80
toStringMethod · 0.80
NewFunction · 0.70
UseMethod · 0.65
SendStringMethod · 0.65

Tested by

no test coverage detected