jschan - Anonymous imageboard software. Classic look, modern features and feel. Works without JavaScript and supports Tor, I2P, Lokinet, etc.
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.
 
 
 
 
 

19 lines
438 B

'use strict';
module.exports = (query, limit) => {
query = query || {};
const nopage = { ...query };
delete nopage.page;
const queryString = new URLSearchParams(nopage).toString();
let page;
if (query.page && Number.isSafeInteger(parseInt(query.page, 10))) {
page = parseInt(query.page, 10);
if (page <= 0) {
page = 1;
}
} else {
page = 1;
}
const offset = (page-1) * limit;
return { queryString, page, offset };
};