rebase migrated WeChat cache URLs
This commit is contained in:
@@ -65,7 +65,15 @@ async function readJson(path) {
|
|||||||
async function cachedResult(id) {
|
async function cachedResult(id) {
|
||||||
try {
|
try {
|
||||||
const result = await readJson(join(articlesDirectory, id, 'result.json'));
|
const result = await readJson(join(articlesDirectory, id, 'result.json'));
|
||||||
return result.status === 'completed' ? result : null;
|
if (result.status !== 'completed') return null;
|
||||||
|
const marker = `/v1/articles/${id}/files/`;
|
||||||
|
for (const field of ['markdown_url', 'pdf_url', 'html_url', 'manifest_url']) {
|
||||||
|
const value = String(result[field] || '');
|
||||||
|
const markerIndex = value.indexOf(marker);
|
||||||
|
if (markerIndex >= 0) result[field] = `${publicBaseUrl}${value.slice(markerIndex)}`;
|
||||||
|
}
|
||||||
|
result.status_url = statusUrl(id);
|
||||||
|
return result;
|
||||||
} catch {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user