This commit is contained in:
Flummi
2021-06-24 05:10:55 +02:00
parent f3e357d8a4
commit 5b7dd4293c
9 changed files with 53 additions and 12 deletions

View File

@ -13,7 +13,12 @@ const allowedMimes = [ "audio", "image", "video", "%" ];
router.get(/^\/(audio\/?|image\/?|video\/?)?(p\/\d+)?$/, async (req, res) => {
const tmpmime = (allowedMimes.filter(n => req.url.split[0].startsWith(n))[0] ? req.url.split[0] : "");
const mime = tmpmime + "%";
const total = (await sql("items").where("mime", "like", mime).count("* as total"))[0].total;
const total = (
await sql("items")
.where("mime", "like", mime)
.count("* as total")
)[0].total;
const pages = +Math.ceil(total / cfg.websrv.eps);
const page = Math.min(pages, +req.url.split[tmpmime.length > 0 ? 2 : 1] || 1);