MCPcopy Create free account
hub / github.com/willnorris/imageproxy / contentTypeMatches

Function contentTypeMatches

imageproxy.go:409–421  ·  view source on GitHub ↗

contentTypeMatches returns whether contentType matches one of the allowed patterns.

(patterns []string, contentType string)

Source from the content-addressed store, hash-verified

407
408// contentTypeMatches returns whether contentType matches one of the allowed patterns.
409func contentTypeMatches(patterns []string, contentType string) bool {
410 if len(patterns) == 0 {
411 return true
412 }
413
414 for _, pattern := range patterns {
415 if ok, err := path.Match(pattern, contentType); ok && err == nil {
416 return true
417 }
418 }
419
420 return false
421}
422
423// hostMatches returns whether the host in u matches one of hosts.
424func hostMatches(hosts []string, u *url.URL) bool {

Callers 2

TestContentTypeMatchesFunction · 0.85
serveImageMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestContentTypeMatchesFunction · 0.68