fix: thumb remove on windows, closes #11357

isekai-main
Barış Soner Uşaklı 2 years ago
parent a3a38e4ba3
commit 767c1d1faf

@ -52,6 +52,7 @@ Thumbs.get = async function (tids) {
const name = path.basename(thumb); const name = path.basename(thumb);
return hasTimestampPrefix.test(name) ? name.slice(14) : name; 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),
}))); })));

@ -3,7 +3,7 @@
<div class="alert alert-info">[[modules:thumbs.modal.no-thumbs]]</div> <div class="alert alert-info">[[modules:thumbs.modal.no-thumbs]]</div>
{{{ end }}} {{{ end }}}
{{{ each thumbs }}} {{{ each thumbs }}}
<div class="media" data-id="{./id}" data-path="{./url}"> <div class="media" data-id="{./id}" data-path="{./path}">
<div class="media-left"> <div class="media-left">
<img class="media-object" src="{./url}" alt="" /> <img class="media-object" src="{./url}" alt="" />
</div> </div>

@ -82,6 +82,7 @@ describe('Topic thumbs', () => {
assert.deepStrictEqual(thumbs, [{ assert.deepStrictEqual(thumbs, [{
id: topicObj.topicData.tid, id: topicObj.topicData.tid,
name: 'test.png', name: 'test.png',
path: `${relativeThumbPaths[0]}`,
url: `${nconf.get('relative_path')}${nconf.get('upload_url')}${relativeThumbPaths[0]}`, url: `${nconf.get('relative_path')}${nconf.get('upload_url')}${relativeThumbPaths[0]}`,
}]); }]);
}); });
@ -92,6 +93,7 @@ describe('Topic thumbs', () => {
[{ [{
id: topicObj.topicData.tid, id: topicObj.topicData.tid,
name: 'test.png', name: 'test.png',
path: `${relativeThumbPaths[0]}`,
url: `${nconf.get('relative_path')}${nconf.get('upload_url')}${relativeThumbPaths[0]}`, url: `${nconf.get('relative_path')}${nconf.get('upload_url')}${relativeThumbPaths[0]}`,
}], }],
[], [],
@ -200,16 +202,19 @@ describe('Topic thumbs', () => {
{ {
id: tid, id: tid,
name: 'test.png', name: 'test.png',
path: relativeThumbPaths[0],
url: `${nconf.get('relative_path')}${nconf.get('upload_url')}${relativeThumbPaths[0]}`, url: `${nconf.get('relative_path')}${nconf.get('upload_url')}${relativeThumbPaths[0]}`,
}, },
{ {
id: tid, id: tid,
name: 'example.org', name: 'example.org',
path: 'https://example.org',
url: 'https://example.org', url: 'https://example.org',
}, },
{ {
id: tid, id: tid,
name: 'test2.png', name: 'test2.png',
path: relativeThumbPaths[1],
url: `${nconf.get('relative_path')}${nconf.get('upload_url')}${relativeThumbPaths[1]}`, url: `${nconf.get('relative_path')}${nconf.get('upload_url')}${relativeThumbPaths[1]}`,
}, },
]); ]);

Loading…
Cancel
Save