librebin url compatibility

This commit is contained in:
b1ek 2023-03-04 12:45:02 +10:00
parent 59f178402e
commit debf79e6fc
Signed by: blek
GPG Key ID: 14546221E3595D0C
2 changed files with 29 additions and 0 deletions

View File

@ -5,4 +5,7 @@ router.use(require('./main'));
router.use(require('./upload')); router.use(require('./upload'));
router.use(require('./view')); router.use(require('./view'));
// librebin url compatibility
router.use(require('./librebin'));
module.exports = router; module.exports = router;

26
routes/librebin.js Normal file
View File

@ -0,0 +1,26 @@
const express = require('express');
const router = express.Router();
const handler = require('express-async-handler');
async function indexphp(req, res) {
if (req.query.p) {
res.redirect('/view?id=' + req.query.p);
return;
}
res.status(400).send('Bad request');
rerturn;
}
async function p(req, res) {
if (!req.params.id) {
res.status(400).send('Bad request');
return;
}
res.redirect('/view?id=' + req.params.id + "&raw=true");
return;
}
router.use('/index.php', handler(indexphp));
router.use('/p/:id', handler(p));
module.exports = router;