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)
| 36 | // domain patterns. Patterns may contain '*' which are matched using the |
| 37 | // internal glob matcher. Matching is case-insensitive on hostnames. |
| 38 | func 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 | |
| 55 | type CookieOpts struct { |
| 56 | Value string |
no test coverage detected