From 374ddc74bd657bb20bf40c6fd7f2944d68b7d85d Mon Sep 17 00:00:00 2001 From: HanYaodong Date: Thu, 13 Jun 2024 10:35:23 +0800 Subject: [PATCH] Use join function for simplicity --- src/routes/postClearCache.ts | 2 +- src/routes/postSkipSegments.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/routes/postClearCache.ts b/src/routes/postClearCache.ts index 29979c09..e446c4b7 100644 --- a/src/routes/postClearCache.ts +++ b/src/routes/postClearCache.ts @@ -23,7 +23,7 @@ export async function postClearCache(req: Request, res: Response): Promise p + (i !== 0 ? ", " : "") + c, ""); + const fields = invalidFields.join(", "); return res.status(400).send(`No valid ${fields} field(s) provided`); } diff --git a/src/routes/postSkipSegments.ts b/src/routes/postSkipSegments.ts index 217be5c9..6ba2eaae 100644 --- a/src/routes/postSkipSegments.ts +++ b/src/routes/postSkipSegments.ts @@ -242,11 +242,11 @@ async function checkInvalidFields(videoID: VideoID, userID: UserID, hashedUserID if (invalidFields.length !== 0) { // invalid request - const formattedFields = invalidFields.reduce((p, c, i) => p + (i !== 0 ? ", " : "") + c, ""); - const formattedErrors = errors.reduce((p, c, i) => p + (i !== 0 ? ". " : " ") + c, ""); + const formattedFields = invalidFields.join(", "); + const formattedErrors = errors.join(". "); return { pass: false, - errorMessage: `No valid ${formattedFields}.${formattedErrors}`, + errorMessage: `No valid ${formattedFields}. ${formattedErrors}`, errorCode: 400 }; }