MCPcopy
hub / github.com/TecharoHQ/anubis / matchRedirectDomain

Function matchRedirectDomain

lib/http.go:38–53  ·  view source on GitHub ↗

matchRedirectDomain returns true if host matches any of the allowed redirect domain patterns. Patterns may contain '*' which are matched using the internal glob matcher. Matching is case-insensitive on hostnames.

(allowed []string, host string)

Source from the content-addressed store, hash-verified

36// domain patterns. Patterns may contain '*' which are matched using the
37// internal glob matcher. Matching is case-insensitive on hostnames.
38func matchRedirectDomain(allowed []string, host string) bool {
39 h := strings.ToLower(strings.TrimSpace(host))
40 for _, pat := range allowed {
41 p := strings.ToLower(strings.TrimSpace(pat))
42 if strings.Contains(p, glob.GLOB) {
43 if glob.Glob(p, h) {
44 return true
45 }
46 continue
47 }
48 if p == h {
49 return true
50 }
51 }
52 return false
53}
54
55type CookieOpts struct {
56 Value string

Callers 3

constructRedirectURLMethod · 0.85
ServeHTTPNextMethod · 0.85
PassChallengeMethod · 0.85

Calls 2

GlobFunction · 0.92
ContainsMethod · 0.45

Tested by

no test coverage detected