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

Function Match

internal/schemehost/schemehost.go:21–29  ·  view source on GitHub ↗

Match reports whether (schemeA, hostA) and (schemeB, hostB) denote the same origin. Scheme comparison is case-insensitive and default ports (http:80, https:443) are normalized so "example.com" and "example.com:443" match.

(schemeA, hostA, schemeB, hostB string)

Source from the content-addressed store, hash-verified

19// origin. Scheme comparison is case-insensitive and default ports (http:80,
20// https:443) are normalized so "example.com" and "example.com:443" match.
21func Match(schemeA, hostA, schemeB, hostB string) bool {
22 normalizedSchemeA := utilsstrings.ToLower(schemeA)
23 normalizedSchemeB := utilsstrings.ToLower(schemeB)
24
25 normalizedHostA := normalizeSchemeHost(normalizedSchemeA, hostA)
26 normalizedHostB := normalizeSchemeHost(normalizedSchemeB, hostB)
27
28 return normalizedSchemeA == normalizedSchemeB && normalizedHostA == normalizedHostB
29}
30
31func normalizeSchemeHost(scheme, host string) string {
32 host = utilsstrings.ToLower(host)

Callers 5

BackMethod · 0.92
originMatchesHostFunction · 0.92
refererMatchesHostFunction · 0.92
Test_MatchFunction · 0.85
Benchmark_MatchFunction · 0.85

Calls 1

normalizeSchemeHostFunction · 0.85

Tested by 2

Test_MatchFunction · 0.68
Benchmark_MatchFunction · 0.68