Skip to content

Commit c6c4d5c

Browse files
committed
update object count logic
1 parent 475a8c5 commit c6c4d5c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/requests.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ export const countObjectNameAppearances = async (
475475
path: string,
476476
originalName: string
477477
): Promise<number> => {
478-
let counter: number = 0;
478+
let dirCount: { [fileName: string]: number } = {};
479479
path = path.substring(0, path.lastIndexOf('/'));
480480

481481
const response = await requestAPI<any>(
@@ -489,11 +489,14 @@ export const countObjectNameAppearances = async (
489489
if (
490490
fileName.substring(0, originalName.length + 1).includes(originalName)
491491
) {
492-
counter += 1;
492+
dirCount[fileName] = 1;
493493
}
494494
});
495495
}
496-
496+
const counter = Object.values(dirCount).reduce(
497+
(sum, count) => sum + count,
498+
0
499+
);
497500
return counter;
498501
};
499502

0 commit comments

Comments
 (0)