diff --git a/index.js b/index.js index 6e7562d24..433ed0698 100644 --- a/index.js +++ b/index.js @@ -557,41 +557,7 @@ function addMetadata(parentComponent = {}, options = {}, context = {}) { } } if (parentComponent?.components) { - const parentFullName = componentToSimpleFullName(parentComponent); - const subComponents = []; - const addedSubComponents = {}; - for (const comp of parentComponent.components) { - cleanParentComponent(comp); - if (comp.name && comp.type) { - const fullName = componentToSimpleFullName(comp); - // Fixes #479 - // Prevent the parent component from also appearing as a sub-component - // We cannot use purl or bom-ref here since they would not match - // purl - could have application on one side and a different type - // bom-ref could have qualifiers on one side - // Ignore components that have the same name as the parent component but with latest as the version. - // These are default components created based on directory names - if ( - fullName !== parentFullName && - !( - (comp.name === parentComponent.name || - comp.name === `${parentComponent.name}:latest`) && - comp.version === "latest" - ) - ) { - if (!comp["bom-ref"]) { - comp["bom-ref"] = `pkg:${comp.type}/${decodeURIComponent( - fullName, - )}`; - } - if (!addedSubComponents[comp["bom-ref"]]) { - subComponents.push(comp); - addedSubComponents[comp["bom-ref"]] = true; - } - } - } - } // for - parentComponent.components = subComponents; + parentComponent.components = listComponents(options, {}, parentComponent.components); } metadata.component = parentComponent; }