From 1abe1d5e012301feeb50601a5e6318d1f91dc453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sat, 17 Jun 2023 19:23:36 -0400 Subject: [PATCH] testing thumb fix (#11727) * testing thumb fix * one more test * remove logs --- src/posts/uploads.js | 4 ++-- src/topics/thumbs.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/posts/uploads.js b/src/posts/uploads.js index c8c12999d5..3ab2a6aeb4 100644 --- a/src/posts/uploads.js +++ b/src/posts/uploads.js @@ -64,10 +64,10 @@ module.exports = function (Posts) { if (isMainPost) { const tid = await Posts.getPostField(pid, 'tid'); let thumbs = await topics.thumbs.get(tid); - const replacePath = path.posix.join(`${nconf.get('relative_path')}${nconf.get('upload_url')}/`); - thumbs = thumbs.map(thumb => thumb.url.replace(replacePath, '')).filter(path => !validator.isURL(path, { + thumbs = thumbs.map(thumb => thumb.path).filter(path => !validator.isURL(path, { require_protocol: true, })); + thumbs = thumbs.map(t => t.slice(1)); // remove leading `/` or `\\` on windows uploads.push(...thumbs); } diff --git a/src/topics/thumbs.js b/src/topics/thumbs.js index 60db184339..f6dcdd2187 100644 --- a/src/topics/thumbs.js +++ b/src/topics/thumbs.js @@ -53,7 +53,7 @@ Thumbs.get = async function (tids) { return hasTimestampPrefix.test(name) ? name.slice(14) : name; })(), path: thumb, - url: thumb.startsWith('http') ? thumb : path.posix.join(upload_url, thumb), + url: thumb.startsWith('http') ? thumb : path.posix.join(upload_url, thumb.replace(/\\/g, '/')), }))); ({ thumbs: response } = await plugins.hooks.fire('filter:topics.getThumbs', { tids, thumbs: response }));