Skip to content

Commit

Permalink
Use join function for simplicity
Browse files Browse the repository at this point in the history
  • Loading branch information
hanydd committed Jun 25, 2024
1 parent 738f863 commit 374ddc7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/routes/postClearCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function postClearCache(req: Request, res: Response): Promise<Respo

if (invalidFields.length !== 0) {
// invalid request
const fields = invalidFields.reduce((p, c, i) => p + (i !== 0 ? ", " : "") + c, "");
const fields = invalidFields.join(", ");
return res.status(400).send(`No valid ${fields} field(s) provided`);
}

Expand Down
6 changes: 3 additions & 3 deletions src/routes/postSkipSegments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
}
Expand Down

0 comments on commit 374ddc7

Please sign in to comment.