MCPcopy
hub / github.com/willnorris/imageproxy / referrerMatches

Function referrerMatches

imageproxy.go:448–455  ·  view source on GitHub ↗

returns whether the referrer from the request is in the host list.

(hosts []string, r *http.Request)

Source from the content-addressed store, hash-verified

446
447// returns whether the referrer from the request is in the host list.
448func referrerMatches(hosts []string, r *http.Request) bool {
449 u, err := url.Parse(r.Header.Get("Referer"))
450 if err != nil { // malformed or blank header, just deny
451 return false
452 }
453
454 return hostMatches(hosts, u)
455}
456
457// validSignature returns whether the request signature is valid.
458func validSignature(key []byte, r *Request) bool {

Callers 2

TestReferrerMatchesFunction · 0.85
allowedMethod · 0.85

Calls 2

hostMatchesFunction · 0.85
GetMethod · 0.65

Tested by 1

TestReferrerMatchesFunction · 0.68