in packages/rulesets/src/spectral/functions/utils.ts [264:284]
export function getResourcesPathHierarchyBasedOnResourceType(path: string) {
const index = path.lastIndexOf("/providers/")
if (index === -1) {
return []
}
const lastProvider = path.substr(index)
const result = []
const matches = lastProvider.match(resourcePathRegEx)
if (matches && matches.length) {
const match = matches[0]
// slice the array to remove 'providers', provider namespace
const resourcePathSegments = match.split("/").slice(3)
for (const resourcePathSegment of resourcePathSegments) {
if (resourcePathSegment.startsWith("{") || resourcePathSegment === "default") {
continue
}
result.push(resourcePathSegment)
}
}
return result
}