mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
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:
@@ -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));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user