Home / Function/ Test_NormalizeDomain() — fiber Function Reference

Test_NormalizeDomain() — fiber Function Reference

Architecture documentation for the Test_NormalizeDomain() function in utils_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  fbb92e7c_b016_15d4_2c7c_179a7a15591c["Test_NormalizeDomain()"]
  31acac19_a947_56a9_0afe_d7291e6d45a1["utils_test.go"]
  fbb92e7c_b016_15d4_2c7c_179a7a15591c -->|defined in| 31acac19_a947_56a9_0afe_d7291e6d45a1
  style fbb92e7c_b016_15d4_2c7c_179a7a15591c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

middleware/cors/utils_test.go lines 86–114

func Test_NormalizeDomain(t *testing.T) {
	testCases := []struct {
		input          string
		expectedOutput string
	}{
		{input: "http://example.com", expectedOutput: "example.com"},                     // Simple case with http scheme.
		{input: "https://example.com", expectedOutput: "example.com"},                    // Simple case with https scheme.
		{input: "http://example.com:3000", expectedOutput: "example.com"},                // Case with port.
		{input: "https://example.com:3000", expectedOutput: "example.com"},               // Case with port and https scheme.
		{input: "http://example.com/path", expectedOutput: "example.com/path"},           // Case with path.
		{input: "http://example.com?query=123", expectedOutput: "example.com?query=123"}, // Case with query.
		{input: "http://example.com#fragment", expectedOutput: "example.com#fragment"},   // Case with fragment.
		{input: "example.com", expectedOutput: "example.com"},                            // Case without scheme.
		{input: "example.com:8080", expectedOutput: "example.com"},                       // Case without scheme but with port.
		{input: "sub.example.com", expectedOutput: "sub.example.com"},                    // Case with subdomain.
		{input: "sub.sub.example.com", expectedOutput: "sub.sub.example.com"},            // Case with nested subdomain.
		{input: "http://localhost", expectedOutput: "localhost"},                         // Case with localhost.
		{input: "http://127.0.0.1", expectedOutput: "127.0.0.1"},                         // Case with IPv4 address.
		{input: "http://[::1]", expectedOutput: "[::1]"},                                 // Case with IPv6 address.
	}

	for _, tc := range testCases {
		output := normalizeDomain(tc.input)

		if output != tc.expectedOutput {
			t.Errorf("Expected normalized domain '%s' for input '%s', but got: '%s'", tc.expectedOutput, tc.input, output)
		}
	}
}

Domain

Subdomains

Frequently Asked Questions

What does Test_NormalizeDomain() do?
Test_NormalizeDomain() is a function in the fiber codebase, defined in middleware/cors/utils_test.go.
Where is Test_NormalizeDomain() defined?
Test_NormalizeDomain() is defined in middleware/cors/utils_test.go at line 86.

Analyze Your Own Codebase

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

Try Supermodel Free