librebin url compatibility
This commit is contained in:
parent
59f178402e
commit
debf79e6fc
|
@ -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;
|
|
@ -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;
|
Loading…
Reference in New Issue