mirror of https://gitgud.io/fatchan/jschan.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
407 B
18 lines
407 B
'use strict';
|
|
|
|
module.exports = (query, limit) => {
|
|
const nopage = { ...query };
|
|
delete nopage.page;
|
|
const queryString = new URLSearchParams(nopage).toString();
|
|
let page;
|
|
if (query.page && Number.isSafeInteger(parseInt(query.page))) {
|
|
page = parseInt(query.page);
|
|
if (page <= 0) {
|
|
page = 1;
|
|
}
|
|
} else {
|
|
page = 1;
|
|
}
|
|
const offset = (page-1) * limit;
|
|
return { queryString, page, offset };
|
|
}
|
|
|