func()

in pkg/brownfield/targets.go [77:107]


func (p TargetPath) contains(otherPath TargetPath) bool {
	if p == "" || p == "*" || p == "/*" {
		return true
	}

	// For strings that do not end with a * - do exact match
	if !strings.HasSuffix(p.lower(), "*") {
		return p.lower() == otherPath.lower()
	}

	// "/x/*" contains "/x"
	if strings.TrimRight(p.lower(), "/*") == strings.TrimRight(otherPath.lower(), "/*") {
		return true
	}

	if len(p) > len(otherPath) {
		return false
	}

	thisPathChunks := strings.Split(p.lower(), "/")
	otherPathChunks := strings.Split(otherPath.lower(), "/")
	for idx := range thisPathChunks {
		if thisPathChunks[idx] == "*" {
			return true
		}
		if thisPathChunks[idx] != otherPathChunks[idx] {
			return false
		}
	}
	return false
}