修复Slug问题

v1.18.x
落雨楓 3 years ago
parent 0409403f5b
commit 04409632dd

@ -50,7 +50,7 @@ categoryController.get = async function (req, res, next) {
return helpers.notAllowed(req, res);
}
if (!res.locals.isAPI && !req.params.slug && (categoryFields.slug && categoryFields.slug !== `${cid}/`)) {
if (!res.locals.isAPI && !req.params.slug && (categoryFields.slug && categoryFields.slug !== `${cid}`)) {
return helpers.redirect(res, `/category/${categoryFields.slug}?${qs.stringify(req.query)}`, true);
}

@ -58,7 +58,7 @@ topicsController.get = async function getTopic(req, res, callback) {
return helpers.notAllowed(req, res);
}
if (!res.locals.isAPI && (!req.params.slug || topicData.slug !== `${tid}/${req.params.slug}`) && (topicData.slug && topicData.slug !== `${tid}/`)) {
if (!res.locals.isAPI && (!req.params.slug || topicData.slug !== `${tid}/${req.params.slug}`) && (topicData.slug && topicData.slug !== `${tid}`)) {
return helpers.redirect(res, `/topic/${topicData.slug}${postIndex ? `/${postIndex}` : ''}${generateQueryString(req.query)}`, true);
}

Loading…
Cancel
Save