Skip to content

Commit 3da0721

Browse files
authored
feat(route): fix images not displaying in msn news full text (#18017)
* feat(route): fix images not displaying in msn news full text * feat(route): fix images not displaying in msn news full text
1 parent 7d1fa06 commit 3da0721

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/routes/msn/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import cache from '@/utils/cache';
55
import { load } from 'cheerio';
66

77
const apiKey = '0QfOX3Vn51YCzitbLaRkTTBadtWpgTN8NZLW0C1SEM';
8+
const fetchedArticleContentHtmlImgRegex = /<img data-reference="image" data-document-id="cms\/api\/amp\/image\/([A-Za-z0-9]+)">/;
89

910
export const route: Route = {
1011
path: '/:market/:name/:id',
@@ -57,8 +58,8 @@ export const route: Route = {
5758
const fetchedArticleContentHtml = (await cache.tryGet(articleId, async () => {
5859
const articleData = await ofetch(`https://assets.msn.com/content/view/v2/Detail/${market}/${articleId}`);
5960
return articleData.body;
60-
})) as string; // cache article content for 3 months
61-
articleContentHtml = fetchedArticleContentHtml;
61+
})) as string;
62+
articleContentHtml = fetchedArticleContentHtml.replace(fetchedArticleContentHtmlImgRegex, '<img src="https://img-s-msn-com.akamaized.net/tenant/amp/entityid/$1.img">');
6263
}
6364

6465
return {

0 commit comments

Comments
 (0)