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

Function Test_Match

internal/schemehost/schemehost_test.go:99–120  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

97}
98
99func Test_Match(t *testing.T) {
100 t.Parallel()
101 tests := []struct {
102 schemeA, hostA, schemeB, hostB string
103 want bool
104 }{
105 {"https", "example.com", "https", "example.com", true},
106 {"https", "example.com", "https", "example.com:443", true},
107 {"http", "example.com", "http", "example.com:80", true},
108 {"https", "example.com:443", "https", "example.com:443", true},
109 {"HTTPS", "Example.com", "https", "example.com", true},
110 {"https", "example.com", "http", "example.com", false},
111 {"https", "example.com", "https", "evil.com", false},
112 {"https", "example.com:8080", "https", "example.com", false},
113 {"https", "[::1]", "https", "[::1]:443", true},
114 {"https", "[::1]:8080", "https", "[::1]", false},
115 }
116 for _, tc := range tests {
117 got := Match(tc.schemeA, tc.hostA, tc.schemeB, tc.hostB)
118 assert.Equal(t, tc.want, got, "Match(%q,%q,%q,%q)", tc.schemeA, tc.hostA, tc.schemeB, tc.hostB)
119 }
120}
121
122func Benchmark_normalizeSchemeHost(b *testing.B) {
123 cases := []struct{ name, scheme, host string }{

Callers

nothing calls this directly

Calls 1

MatchFunction · 0.85

Tested by

no test coverage detected