From 185babc53f350949263c79da4733483a4e451fc4 Mon Sep 17 00:00:00 2001 From: Juan Picado Date: Sun, 22 Nov 2020 13:55:14 +0100 Subject: [PATCH] fix: check author if lastest is not found (#1994) --- src/api/web/endpoint/package.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/api/web/endpoint/package.ts b/src/api/web/endpoint/package.ts index 4e6e818e4..eeb593f32 100644 --- a/src/api/web/endpoint/package.ts +++ b/src/api/web/endpoint/package.ts @@ -125,7 +125,13 @@ function addPackageWebApi(route: Router, storage: IStorageHandler, auth: IAuth, sideBarInfo.latest.author = formatAuthor(sideBarInfo.latest.author); } else { sideBarInfo.latest = sideBarInfo.versions[info[DIST_TAGS].latest]; - sideBarInfo.latest.author = formatAuthor(sideBarInfo.latest.author); + if (sideBarInfo?.latest) { + sideBarInfo.latest.author = formatAuthor(sideBarInfo.latest.author); + } else { + res.status(HTTP_STATUS.NOT_FOUND); + res.end(); + return; + } } sideBarInfo = deleteProperties(['readme', '_attachments', '_rev', 'name'], sideBarInfo); if (config.web) {