fix: restore public page share thumbnails from SVG sidecars
Serve missing *.thumbnail.png requests when the SVG sidecar exists, and schedule async PNG rasterization after public HTML is materialized so WeChat og:image URLs stop 404ing. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -120,3 +120,30 @@ test('resolveMindSpacePublicRequest coordinates canonical redirect, serve, and n
|
||||
ownerKey,
|
||||
});
|
||||
});
|
||||
|
||||
test('resolveMindSpacePublicRequest serves missing thumbnail png when svg sidecar exists', async () => {
|
||||
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'ms-public-thumb-'));
|
||||
const ownerKey = '123e4567-e89b-12d3-a456-426614174000';
|
||||
const targetDir = path.join(root, 'MindSpace', ownerKey);
|
||||
const publicDir = path.join(targetDir, 'public');
|
||||
fs.mkdirSync(publicDir, { recursive: true });
|
||||
fs.writeFileSync(path.join(publicDir, 'report.thumbnail.svg'), '<svg xmlns="http://www.w3.org/2000/svg"></svg>');
|
||||
|
||||
const served = await resolveMindSpacePublicRequest({
|
||||
h5Root: root,
|
||||
requestPath: `/${ownerKey}/public/report.thumbnail.png`,
|
||||
});
|
||||
assert.equal(served.action, 'serve');
|
||||
assert.equal(served.filePath, path.join(publicDir, 'report.thumbnail.png'));
|
||||
assert.equal(fs.existsSync(served.filePath), false);
|
||||
|
||||
const stillMissing = await resolveMindSpacePublicRequest({
|
||||
h5Root: root,
|
||||
requestPath: `/${ownerKey}/public/missing.thumbnail.png`,
|
||||
});
|
||||
assert.deepEqual(stillMissing, {
|
||||
action: 'not_found',
|
||||
reason: 'missing_file',
|
||||
ownerKey,
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user