Node.js based forum software built for the modern web
fix: #10366, remove dupe /files
Barış Soner Uşaklı371b46581a87
diff --git a/src/controllers/topics.js b/src/controllers/topics.jsindex 291acf78cf..ee2f2722cb 100644--- a/src/controllers/topics.js+++ b/src/controllers/topics.js@@ -269,11 +269,15 @@ async function addTags(topicData, req, res) {async function addOGImageTags(res, topicData, postAtIndex) {const uploads = postAtIndex ? await posts.uploads.listWithSizes(postAtIndex.pid) : [];const images = uploads.map((upload) => {- upload.name = `${url + upload_url}/files/${upload.name}`;+ upload.name = `${url + upload_url}/${upload.name}`;return upload;});if (topicData.thumbs) {- images.push(...topicData.thumbs.map(thumbObj => ({ name: nconf.get('url') + thumbObj.url })));+ const path = require('path');+ const thumbs = topicData.thumbs.filter(+ t => t && images.every(img => path.normalize(img.name) !== path.normalize(url + t.url))+ );+ images.push(...thumbs.map(thumbObj => ({ name: url + thumbObj.url })));}if (topicData.category.backgroundImage && (!postAtIndex || !postAtIndex.index)) {images.push(topicData.category.backgroundImage);