From 171017c38c24fa06fee7333ccf955883e393dfab Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 6 Jan 2021 12:15:32 -0500 Subject: [PATCH] fix: #9130, remove timestamp prefix from thumbnail names in API response --- src/topics/thumbs.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/topics/thumbs.js b/src/topics/thumbs.js index a894e12810..d65b99b3c4 100644 --- a/src/topics/thumbs.js +++ b/src/topics/thumbs.js @@ -31,12 +31,16 @@ Thumbs.get = async function (tids) { return singular ? null : tids.map(() => []); } + const hasTimestampPrefix = /^\d+-/; const upload_url = nconf.get('upload_url'); const sets = tids.map(tid => `${validator.isUUID(String(tid)) ? 'draft' : 'topic'}:${tid}:thumbs`); const thumbs = await Promise.all(sets.map(set => getThumbs(set))); let response = thumbs.map((thumbSet, idx) => thumbSet.map(thumb => ({ id: tids[idx], - name: path.basename(thumb), + name: (() => { + const name = path.basename(thumb); + return hasTimestampPrefix.test(name) ? name.slice(14) : name; + })(), url: thumb.startsWith('http') ? thumb : path.posix.join(upload_url, thumb), })));