fix: renderOverride to not clobber url if already set in template data

This commit is contained in:
Julian Lam
2025-11-05 13:42:56 -05:00
parent 172aabcb57
commit 2066727f3e
2 changed files with 10 additions and 5 deletions

View File

@@ -151,7 +151,7 @@ categoryController.get = async function (req, res, next) {
categoryData.selectedTags = tagData.selectedTags;
categoryData.sortOptionLabel = `[[topic:${validator.escape(String(sort)).replace(/_/g, '-')}]]`;
if (!meta.config['feeds:disableRSS']) {
if (utils.isNumber(categoryData.cid) && !meta.config['feeds:disableRSS']) {
categoryData.rssFeedUrl = `${url}/category/${categoryData.cid}.rss`;
if (req.loggedIn) {
categoryData.rssFeedUrl += `?uid=${req.uid}&token=${rssToken}`;
@@ -175,10 +175,15 @@ categoryController.get = async function (req, res, next) {
res.set('Link', `<${nconf.get('url')}/category/${cid}>; rel="alternate"; type="application/activity+json"`);
// Category accessible
const remoteOk = await privileges.categories.can('read', cid, activitypub._constants.uid);
if (remoteOk) {
const federating = await privileges.categories.can('read', cid, activitypub._constants.uid);
if (federating) {
categoryData.handleFull = `${categoryData.handle}@${nconf.get('url_parsed').host}`;
}
// Some remote categories don't have `url`, assume same as id
if (!utils.isNumber(categoryData.cid) && !categoryData.hasOwnProperty('url')) {
categoryData.url = categoryData.cid;
}
}
res.render('category', categoryData);
@@ -247,7 +252,7 @@ function addTags(categoryData, res, currentPage) {
},
];
if (!categoryData['feeds:disableRSS']) {
if (categoryData.rssFeedUrl && !categoryData['feeds:disableRSS']) {
res.locals.linkTags.push({
rel: 'alternate',
type: 'application/rss+xml',

View File

@@ -45,7 +45,7 @@ module.exports = function (middleware) {
options.loggedInUser = await getLoggedInUser(req);
options.relative_path = relative_path;
options.template = { name: template, [template]: true };
options.url = (req.baseUrl + req.path.replace(/^\/api/, ''));
options.url = options.url || (req.baseUrl + req.path.replace(/^\/api/, ''));
options.bodyClass = helpers.buildBodyClass(req, res, options);
if (req.loggedIn) {