Skip to content

Commit

Permalink
Replay search: Default to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
mia-pi-git committed Oct 26, 2023
1 parent 54d978c commit f2d2b92
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -713,9 +713,10 @@ export const actions: {[k: string]: QueryHandler} = {
page: Number(params.page),
byRating: !!params.byRating,
};
if (isNaN(search.page) || search.page !== Math.trunc(search.page)) {
if (isNaN(search.page) || search.page !== Math.trunc(search.page) || search.page < 0) {
throw new ActionError(`Invalid page number: ${params.page}`);
}
if (!search.page) search.page = 1;
return Replays.search(search);
},
async 'replays/searchprivate'(params) {
Expand All @@ -732,9 +733,10 @@ export const actions: {[k: string]: QueryHandler} = {
if (!(this.user.isSysop() || [search.username, search.username2].includes(this.user.id))) {
throw new ActionError(`Access denied.`);
}
if (isNaN(search.page) || search.page !== Math.trunc(search.page)) {
if (isNaN(search.page) || search.page !== Math.trunc(search.page) || search.page < 0) {
throw new ActionError(`Invalid page number: ${params.page}`);
}
if (!search.page) search.page = 1;
return Replays.search(search);
},
};
Expand Down

0 comments on commit f2d2b92

Please sign in to comment.