예제 #1
0
파일: guard.go 프로젝트: zeisss/ladon
func Matches(p policy.Policy, patterns []string, match string) (bool, error) {
	var reg *regexp.Regexp
	var err error
	var matches bool
	for _, h := range patterns {
		reg, err = compiler.CompileRegex(h, p.GetStartDelimiter(), p.GetEndDelimiter())
		if err != nil {
			return false, err
		}

		matches = reg.MatchString(match)
		if matches {
			return true, nil
		}
	}
	return false, nil
}