ExecuteHostnamePattern executes a pattern generated by CompileHostnamePattern and returns the wildcard match. If the pattern does not match the hostname, returns false.
(pattern *regexp.Regexp, hostname string)
| 305 | // and returns the wildcard match. If the pattern does not match the hostname, |
| 306 | // returns false. |
| 307 | func ExecuteHostnamePattern(pattern *regexp.Regexp, hostname string) (string, bool) { |
| 308 | matches := pattern.FindStringSubmatch(hostname) |
| 309 | if len(matches) < 2 { |
| 310 | return "", false |
| 311 | } |
| 312 | |
| 313 | return matches[1], true |
| 314 | } |
| 315 | |
| 316 | // ConvertAppHostForCSP converts the wildcard host to a format accepted by CSP. |
| 317 | // For example *--apps.coder.com must become *.coder.com. If there is no |
no outgoing calls