MCPcopy Index your code
hub / github.com/coder/coder / HostnamesMatch

Function HostnamesMatch

coderd/workspaceapps/appurl/appurl.go:210–224  ·  view source on GitHub ↗

HostnamesMatch returns true if the hostnames are equal, disregarding capitalization, extra leading or trailing periods, and ports.

(a, b string)

Source from the content-addressed store, hash-verified

208// HostnamesMatch returns true if the hostnames are equal, disregarding
209// capitalization, extra leading or trailing periods, and ports.
210func HostnamesMatch(a, b string) bool {
211 a = strings.Trim(a, ".")
212 b = strings.Trim(b, ".")
213
214 aHost, _, err := net.SplitHostPort(a)
215 if err != nil {
216 aHost = a
217 }
218 bHost, _, err := net.SplitHostPort(b)
219 if err != nil {
220 bHost = b
221 }
222
223 return strings.EqualFold(aHost, bHost)
224}
225
226// CompileHostnamePattern compiles a hostname pattern into a regular expression.
227// A hostname pattern is a string that may contain a single wildcard character

Callers 1

parseHostnameMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected