mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-01 21:30:30 +01:00
fix: #9130, remove timestamp prefix from thumbnail names in API response
This commit is contained in:
@@ -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),
|
||||
})));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user