diff --git a/componentDetection.ts b/componentDetection.ts index 9c6e482..afa99ec 100644 --- a/componentDetection.ts +++ b/componentDetection.ts @@ -153,28 +153,31 @@ export default class ComponentDetection { private static addPackagesToManifests(packages: Array, manifests: Array, dependencyGraphs: DependencyGraphs): void { packages.forEach((pkg: ComponentDetectionPackage) => { pkg.locationsFoundAt.forEach((location: any) => { - if (!manifests.find((manifest: Manifest) => manifest.name == location)) { - const manifest = new Manifest(location, location); + // Use the normalized path (remove leading slash if present) + const normalizedLocation = location.startsWith('/') ? location.substring(1) : location; + + if (!manifests.find((manifest: Manifest) => manifest.name == normalizedLocation)) { + const manifest = new Manifest(normalizedLocation, normalizedLocation); manifests.push(manifest); } - const depGraphEntry = dependencyGraphs[location]; + const depGraphEntry = dependencyGraphs[normalizedLocation]; if (!depGraphEntry) { - core.warning(`No dependency graph entry found for manifest location: ${location}`); + core.warning(`No dependency graph entry found for manifest location: ${normalizedLocation}`); return; // Skip this location if not found in dependencyGraphs } const directDependencies = depGraphEntry.explicitlyReferencedComponentIds; if (directDependencies.includes(pkg.id)) { manifests - .find((manifest: Manifest) => manifest.name == location) + .find((manifest: Manifest) => manifest.name == normalizedLocation) ?.addDirectDependency( pkg, ComponentDetection.getDependencyScope(pkg) ); } else { manifests - .find((manifest: Manifest) => manifest.name == location) + .find((manifest: Manifest) => manifest.name == normalizedLocation) ?.addIndirectDependency( pkg, ComponentDetection.getDependencyScope(pkg)