INNER CODE UNIT · Go
matches
cloudflare/cf-terraforming · internal/app/cf-terraforming/cmd/import.go:795
matches := r.FindAllString(endpoint, -1)
if len(matches) > 0 {
// Naive assumptions below but if we only have a single placeholder (`{}`)
// we can replace that with the `resourceID` however, if we have more than
// a single one, we assume it is the second match since that is our URL
// conventions.
//
// Note: this will likely break on un-RESTful routes.
if len(matches) == 1 {
matches[0] = resourceID
} else {
if matches[0] == "{account_id}" {
matches[0] = accountID
} else if matches[0] == "{zone_id}" {
matches[0] = zoneID
}
matches[1] = resourceID