Skip to content

Node.js based forum software built for the modern web

fix: duplicate canonical link header

Julian Lamc8ad086779eb
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,
- });
- }
}
}