potential fix for favorites in production, let's try
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import cfg from "../../inc/config.mjs";
|
||||
import lib from "../lib.mjs";
|
||||
import f0cklib from "../routeinc/f0cklib.mjs";
|
||||
|
||||
export default (router, tpl) => {
|
||||
@@ -7,12 +6,14 @@ export default (router, tpl) => {
|
||||
let referer = req.headers.referer ?? '';
|
||||
let opts = {};
|
||||
|
||||
if(referer.match(new RegExp(cfg.main.url.regex))) { // parse referer
|
||||
if (referer.match(new RegExp(cfg.main.url.regex))) { // parse referer
|
||||
referer = referer.split(cfg.main.url.domain)[1];
|
||||
console.log("referer: ", referer);
|
||||
|
||||
const tmp = referer.match(/^\/?(?:\/tag\/(?<tag>.+?))?(?:\/user\/(?<user>.+?)\/(?<mode>f0cks|favs))?(?:\/(?<mime>image|audio|video))?(?:\/p\/(?<page>\d+))?(?:\/(?<itemid>\d+))?$/);
|
||||
console.log("tmp: ", tmp);
|
||||
if(tmp)
|
||||
|
||||
if (tmp && tmp.groups)
|
||||
opts = tmp.groups;
|
||||
}
|
||||
|
||||
@@ -21,14 +22,14 @@ export default (router, tpl) => {
|
||||
tag: opts.tag,
|
||||
mime: opts.mime,
|
||||
page: opts.page,
|
||||
fav: opts.mode == 'favs',
|
||||
fav: opts.mode === 'favs',
|
||||
mode: req.session.mode,
|
||||
session: !!req.session
|
||||
});
|
||||
|
||||
|
||||
console.log("data", data);
|
||||
|
||||
if(!data.success) {
|
||||
if (!data.success) {
|
||||
return res.reply({
|
||||
code: 404,
|
||||
body: tpl.render('error', {
|
||||
@@ -40,5 +41,6 @@ export default (router, tpl) => {
|
||||
|
||||
res.redirect(encodeURI(`${data.link.main}${data.link.path}${data.itemid}`));
|
||||
});
|
||||
|
||||
return router;
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user