fix category link redirect on cold load
fix helpers.redirect if passed in url is external
fix ajaxify so it doesn't slice first character of external url
This commit is contained in:
Barış Soner Uşaklı
2020-11-23 12:25:57 -05:00
parent f33a9185ff
commit 5fa098326f
4 changed files with 35 additions and 11 deletions

View File

@@ -145,9 +145,11 @@ helpers.notAllowed = async function (req, res, error) {
helpers.redirect = function (res, url, permanent) {
if (res.locals.isAPI) {
res.set('X-Redirect', encodeURI(url)).status(200).json(url);
res.set('X-Redirect', encodeURI(url)).status(200).json(encodeURI(url));
} else {
res.redirect(permanent ? 308 : 307, relative_path + encodeURI(url));
const redirectUrl = url.startsWith('http://') || url.startsWith('https://') ?
url : relative_path + url;
res.redirect(permanent ? 308 : 307, encodeURI(redirectUrl));
}
};