Skip to content

Commit 6d25ae1

Browse files
committed
Remove leading slashes from top manifests
1 parent 7d147e8 commit 6d25ae1

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

componentDetection.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,28 +153,31 @@ export default class ComponentDetection {
153153
private static addPackagesToManifests(packages: Array<ComponentDetectionPackage>, manifests: Array<Manifest>, dependencyGraphs: DependencyGraphs): void {
154154
packages.forEach((pkg: ComponentDetectionPackage) => {
155155
pkg.locationsFoundAt.forEach((location: any) => {
156-
if (!manifests.find((manifest: Manifest) => manifest.name == location)) {
157-
const manifest = new Manifest(location, location);
156+
// Use the normalized path (remove leading slash if present)
157+
const normalizedLocation = location.startsWith('/') ? location.substring(1) : location;
158+
159+
if (!manifests.find((manifest: Manifest) => manifest.name == normalizedLocation)) {
160+
const manifest = new Manifest(normalizedLocation, normalizedLocation);
158161
manifests.push(manifest);
159162
}
160163

161-
const depGraphEntry = dependencyGraphs[location];
164+
const depGraphEntry = dependencyGraphs[normalizedLocation];
162165
if (!depGraphEntry) {
163-
core.warning(`No dependency graph entry found for manifest location: ${location}`);
166+
core.warning(`No dependency graph entry found for manifest location: ${normalizedLocation}`);
164167
return; // Skip this location if not found in dependencyGraphs
165168
}
166169

167170
const directDependencies = depGraphEntry.explicitlyReferencedComponentIds;
168171
if (directDependencies.includes(pkg.id)) {
169172
manifests
170-
.find((manifest: Manifest) => manifest.name == location)
173+
.find((manifest: Manifest) => manifest.name == normalizedLocation)
171174
?.addDirectDependency(
172175
pkg,
173176
ComponentDetection.getDependencyScope(pkg)
174177
);
175178
} else {
176179
manifests
177-
.find((manifest: Manifest) => manifest.name == location)
180+
.find((manifest: Manifest) => manifest.name == normalizedLocation)
178181
?.addIndirectDependency(
179182
pkg,
180183
ComponentDetection.getDependencyScope(pkg)

0 commit comments

Comments
 (0)