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 2d42e5a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 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
4 changes: 2 additions & 2 deletions src/routes/postSkipSegments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ 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}`,
Expand Down

0 comments on commit 2d42e5a

Please sign in to comment.