Node.js based forum software built for the modern web
fix: #9130, remove timestamp prefix from thumbnail names in API response
Julian Lam171017c38c24
diff --git a/src/topics/thumbs.js b/src/topics/thumbs.jsindex 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),})));