🧑🏻‍🔧Hardening unrar code

This commit is contained in:
2021-05-04 15:48:14 -07:00
parent b1cb1c2d22
commit f9bad43aab
3 changed files with 26 additions and 59 deletions

View File

@@ -17,7 +17,10 @@ router.route("/getComicCovers").post(async (req: Request, res: Response) => {
? req.body.extractionOptions
: {};
const extractedData = await extractArchive(req.body);
if (_.isArray(extractedData)) {
if (
_.isArray(extractedData) &&
!_.isUndefined(req.body.paginationOptions.pageLimit)
) {
const pageCount = Math.ceil(
extractedData.length / req.body.paginationOptions.pageLimit,
);
@@ -27,11 +30,6 @@ router.route("/getComicCovers").post(async (req: Request, res: Response) => {
has_more: paginate.hasNextPages(req)(pageCount),
pageCount,
itemCount: extractedData.length,
pages: paginate.getArrayPages(req)(
3,
pageCount,
req.body.paginationOptions.page,
),
extractedData,
});
}