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

Function Test_App_Use_UnescapedPath

app_test.go:859–886  ·  app_test.go::Test_App_Use_UnescapedPath
(t *testing.T)

Source from the content-addressed store, hash-verified

857}
858
859func Test_App_Use_UnescapedPath(t *testing.T) {
860 t.Parallel()
861 app := New(Config{UnescapePath: true, CaseSensitive: true})
862
863 app.Use("/cRéeR/:param", func(c Ctx) error {
864 require.Equal(t, "/cRéeR/اختبار", c.Path())
865 return c.SendString(c.Params("param"))
866 })
867
868 app.Use("/abc", func(c Ctx) error {
869 require.Equal(t, "/AbC", c.Path())
870 return nil
871 })
872
873 resp, err := app.Test(httptest.NewRequest(MethodGet, "/cR%C3%A9eR/%D8%A7%D8%AE%D8%AA%D8%A8%D8%A7%D8%B1", http.NoBody))
874 require.NoError(t, err, "app.Test(req)")
875 require.Equal(t, StatusOK, resp.StatusCode, "Status code")
876
877 body, err := io.ReadAll(resp.Body)
878 require.NoError(t, err, "app.Test(req)")
879 // check the param result
880 require.Equal(t, "اختبار", app.toString(body))
881
882 // with lowercase letters
883 resp, err = app.Test(httptest.NewRequest(MethodGet, "/cr%C3%A9er/%D8%A7%D8%AE%D8%AA%D8%A8%D8%A7%D8%B1", http.NoBody))
884 require.NoError(t, err, "app.Test(req)")
885 require.Equal(t, StatusNotFound, resp.StatusCode, "Status code")
886}
887
888func Test_App_Use_CaseSensitive(t *testing.T) {
889 t.Parallel()

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected