Home / Function/ Test_Extractor_URL_Encoded() — fiber Function Reference

Test_Extractor_URL_Encoded() — fiber Function Reference

Architecture documentation for the Test_Extractor_URL_Encoded() function in extractors_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  9aa9d288_5ce6_be78_a43b_85d081825925["Test_Extractor_URL_Encoded()"]
  cf5e296e_8db5_6f84_b05a_9c0cac6f83e7["extractors_test.go"]
  9aa9d288_5ce6_be78_a43b_85d081825925 -->|defined in| cf5e296e_8db5_6f84_b05a_9c0cac6f83e7
  564f4da6_d93f_44ce_5143_1a130449b5d9["newRequest()"]
  9aa9d288_5ce6_be78_a43b_85d081825925 -->|calls| 564f4da6_d93f_44ce_5143_1a130449b5d9
  style 9aa9d288_5ce6_be78_a43b_85d081825925 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

extractors/extractors_test.go lines 845–900

func Test_Extractor_URL_Encoded(t *testing.T) {
	t.Parallel()

	t.Run("FromQuery_with_spaces", func(t *testing.T) {
		t.Parallel()

		app := fiber.New()
		ctx := app.AcquireCtx(&fasthttp.RequestCtx{})
		t.Cleanup(func() { app.ReleaseCtx(ctx) })
		ctx.Request().SetRequestURI("/?token=token%20with%20spaces")
		token, err := FromQuery("token").Extract(ctx)
		require.NoError(t, err)
		require.Equal(t, "token with spaces", token) // Should be URL-decoded automatically by fasthttp
	})

	t.Run("FromForm_with_plus", func(t *testing.T) {
		t.Parallel()

		app := fiber.New()
		ctx := app.AcquireCtx(&fasthttp.RequestCtx{})
		t.Cleanup(func() { app.ReleaseCtx(ctx) })
		ctx.Request().Header.SetContentType(fiber.MIMEApplicationForm)
		ctx.Request().Header.SetMethod(fiber.MethodPost)
		ctx.Request().SetBodyString("token=token%2Bwith%2Bplus")
		token, err := FromForm("token").Extract(ctx)
		require.NoError(t, err)
		require.Equal(t, "token+with+plus", token) // URL-decoded
	})

	t.Run("FromQuery_base64_encoded", func(t *testing.T) {
		t.Parallel()

		app := fiber.New()
		ctx := app.AcquireCtx(&fasthttp.RequestCtx{})
		t.Cleanup(func() { app.ReleaseCtx(ctx) })
		base64Value := "cGFzc3dvcmQ%3D" // URL-encoded base64 "cGFzc3dvcmQ="
		ctx.Request().SetRequestURI("/?token=" + base64Value)
		token, err := FromQuery("token").Extract(ctx)
		require.NoError(t, err)
		require.Equal(t, "cGFzc3dvcmQ=", token) // Should be URL-decoded
	})

	t.Run("FromParam_with_slashes", func(t *testing.T) {
		t.Parallel()

		app := fiber.New()
		app.Get("/test/:token", func(c fiber.Ctx) error {
			token, extractErr := FromParam("token").Extract(c)
			require.NoError(t, extractErr)
			require.Equal(t, "token/with/slashes", token)
			return nil
		})
		_, err := app.Test(newRequest(fiber.MethodGet, "/test/token%2Fwith%2Fslashes"))
		require.NoError(t, err)
	})
}

Domain

Subdomains

Calls

Frequently Asked Questions

What does Test_Extractor_URL_Encoded() do?
Test_Extractor_URL_Encoded() is a function in the fiber codebase, defined in extractors/extractors_test.go.
Where is Test_Extractor_URL_Encoded() defined?
Test_Extractor_URL_Encoded() is defined in extractors/extractors_test.go at line 845.
What does Test_Extractor_URL_Encoded() call?
Test_Extractor_URL_Encoded() calls 1 function(s): newRequest.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free