// matches checks if given req.URL is a match with a mapping. Match can be either full, partial (http method mismatch) or no match.
436555
func (m *mapping) matches(req *http.Request) (match matchType, method string) {
	if !m.path.MatchString(req.URL.Path) {
		match, method = noMatch, ""
	} else if m.method != req.Method {
		match, method = pathMatch, m.method
	} else {
		match, method = fullMatch, m.method
	}
	return
}
733994
func match(a, b string) bool {
	if wildcard(a) {
		return true
	}
	if wildcard(b) {
		return true
	}
	return strings.EqualFold(a, b)
}
326466
func (r *ResponseMatcher) match(res *http.Response) (bool, int) {
	if r.method != "" {
		if r.method != res.Request.Method {
			return false, 0
		}
	}
	if r.contentType != "" {
		if r.contentType != getContentType(res.Header.Get("Content-Type")) {
			return false, 0
		}
	}
	if r.minStatus != 0 || r.maxStatus != 0 {
		if res.StatusCode < r.minStatus || res.StatusCode > r.maxStatus {
			return false, 0
		}
	}
	if r.scheme != "" {
		if res.Request.URL.Scheme != r.scheme {
			return false, 0
		}
	}
	if r.host != "" {
		if res.Request.URL.Host != r.host {
			return false, 0
		}
	}
	if r.predicate != nil {
		if !r.predicate(res) {
			return false, 0
		}
	}
	if r.path != "" {
		if strings.HasPrefix(res.Request.URL.Path, r.path) {
			return true, len(r.path)
		}
		return false, 0
	}
	return true, 0
}
1274094
func (rule *Rule) Matches(data interface{}) bool {
	log.Debugf("memcache checking rule %v", *rule)

	packetMeta, ok := data.(meta.MemcacheMeta)

	if !ok {
		log.Debugf("Wrong type supplied to Rule.Matches")
		return false
	}

	if rule.empty {
		return true
	}

	if packetMeta.IsBinary() {
		if !rule.matchOpcode(packetMeta.Opcode) {
			return false
		}
	} else {
		if !rule.matchCommand(packetMeta.Command) {
			return false
		}
	}

	if len(rule.keyExact) > 0 {
		for _, key := range packetMeta.Keys {
			if !bytes.Equal(rule.keyExact, key) {
				return false
			}
		}
		return true
	}

	if len(rule.keyPrefix) > 0 {
		for _, key := range packetMeta.Keys {
			if !bytes.HasPrefix(key, rule.keyPrefix) {
				return false
			}
		}
		return true
	}

	if rule.regex != nil {
		for _, key := range packetMeta.Keys {
			if !rule.regex.Match(key) {
				return false
			}
		}
		return true
	}

	log.Debugf("No key rule specified, accepted by command match")
	return true
}
540637
func (r *Rule) Matches(msg map[string]interface{}) bool {
	for field, values := range r.Matchers {
		if !fieldMatches(field, values, msg) {
			return false
		}
	}
	return true
}
523197
func (m *MockMatcher) Matches(arg0 interface{}) bool {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Matches", arg0)
	ret0, _ := ret[0].(bool)
	return ret0
}
921210
func (rule *PathCacheRule) matches(req *http.Request, statusCode int, respHeaders http.Header) bool {
	return strings.HasPrefix(req.URL.Path, rule.Path)
}
238877
func (s *SimpleRule) Match(r *http.Request) bool {
	matches := regexpMatches(s.Regexp, "/", r.URL.Path)
	if s.Negate {
		return len(matches) == 0
	}
	return len(matches) > 0
}
899545
func MatchHost(req *http.Request, ereq *Request) (bool, error) {
	url := ereq.URLStruct
	if strings.EqualFold(url.Host, req.URL.Host) {
		return true, nil
	}
	return regexp.MatchString(url.Host, req.URL.Host)
}
432207
func Match(methods []string, path string, h interface{}, m ...interface{}) {
	Default.Match(methods, path, h, m...)
}
1111386
func (a acceptCriterion) matches(t string) bool {
	st := strings.SplitN(t, "/", 2)

	if a.major != "*" && a.major != st[0] {
		return false
	}
	if a.minor != "*" && a.minor != st[1] {
		return false
	}
	return true
}
865966
func matches(re *regexp.Regexp, filename, template string) (match bool, origin string) {
	base := path.Base(filename)

	matches := re.FindStringSubmatchIndex(base)
	if matches == nil {
		return false, ""
	}

	by := re.ExpandString(nil, template, base, matches)
	if by == nil {
		return false, ""
	}

	origin = dns.Fqdn(string(by))

	return true, origin
}
1273355
func match(r *http.Request, sess *sessions.Session, refresh bool) bool {

	valid := false
	path := r.URL.Path

	if SingleToken {
		path = "/"
	}

	// If tokens exists
	if token, ok := sess.Values[TokenName]; ok {

		// Token submitted via POST
		sentToken := r.FormValue(TokenName)

		// Detect the content type
		switch r.Header.Get("Content-Type") {
		case "application/x-www-form-urlencoded":
			sentToken = r.FormValue(TokenName)
			break
		case "application/json":
			// Prevents throwing an error if nil
			b := bytes.NewBuffer(make([]byte, 0))
			body_reader := io.TeeReader(r.Body, b)
			if r.Body == nil {
				break
			}
			var t interface{}
			decoder := json.NewDecoder(body_reader)
			err := decoder.Decode(&t)

			// If the response is JSON
			if err == nil {
				vals := t.(map[string]interface{})
				// Update the token value
				sentToken = fmt.Sprintf("%v", vals[TokenName])
			}
			r.Body = ioutil.NopCloser(b)
			break
		}

		// If token is empty in the form, it is not valid
		if sentToken == "" {
			valid = false
		} else {
			// Check token against same page URL
			if sentToken == token.(StringMap)[path] {
				valid = true
			} else {
				// Extract the relative referer path
				offset := strings.Index(r.Referer(), r.Host) + len(r.Host)

				// Make sure no errors can be thrown
				if offset != 0 && offset < len(r.Referer()) {
					// Check token against previous page
					if sentToken == token.(StringMap)[r.Referer()[offset:]] {
						valid = true
					}
				}

			}
		}

		if refresh {
			delete(token.(StringMap), path)
		}
	}

	return valid
}
291740
func (n Name) Matches(child string) bool {
	if dns.Name(n) == dns.Name(child) {
		return true
	}
	return dns.IsSubDomain(string(n), child)
}
715964
func (t *docMatchTree) matches(cp *contentProvider, cost int, known map[matchTree]bool) (bool, bool) {
	return len(t.current) > 0, true
}
1036175
func (g *routeGroup) Match(methods []string, path string, h ...Handler) {
	for _, m := range methods {
		g.handle(m, path, h)
	}
}
994289
func MatchPath(req *http.Request, ereq *Request) (bool, error) {
	if req.URL.Path == ereq.URLStruct.Path {
		return true, nil
	}
	return regexp.MatchString(ereq.URLStruct.Path, req.URL.Path)
}