From c8ad086779eb4ff56cb2063f9ce0e99532c23571 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Sat, 2 Aug 2025 09:52:13 -0400 Subject: [PATCH] fix: duplicate canonical link header --- src/controllers/accounts/profile.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/controllers/accounts/profile.js b/src/controllers/accounts/profile.js index de0e744eb5..f235a3c69a 100644 --- a/src/controllers/accounts/profile.js +++ b/src/controllers/accounts/profile.js @@ -167,10 +167,17 @@ function addTags(res, userData) { res.locals.linkTags = []; - res.locals.linkTags.push({ - rel: 'canonical', - href: `${url}/user/${userData.userslug}`, - }); + if (utils.isNumber(userData.uid)) { + res.locals.linkTags.push({ + rel: 'canonical', + href: `${url}/user/${userData.userslug}`, + }); + } else { + res.locals.linkTags.push({ + rel: 'canonical', + href: userData.url || userData.uid, + }); + } if (meta.config.activitypubEnabled) { res.locals.linkTags.push({ @@ -178,12 +185,5 @@ function addTags(res, userData) { type: 'application/activity+json', href: `${nconf.get('url')}/uid/${userData.uid}`, }); - - if (!utils.isNumber(userData.uid)) { - res.locals.linkTags.push({ - rel: 'canonical', - href: userData.url || userData.uid, - }); - } } }