From 9fafbd2019272386d74ab915a725d6a097f09f10 Mon Sep 17 00:00:00 2001 From: KTachibanaM Date: Wed, 1 Jan 2025 06:38:58 +0000 Subject: [PATCH 1/2] feat(route): fix images not displaying in msn news full text --- lib/routes/msn/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/routes/msn/index.ts b/lib/routes/msn/index.ts index 5ca954bbeb7fcc..216cc52312e30c 100644 --- a/lib/routes/msn/index.ts +++ b/lib/routes/msn/index.ts @@ -5,6 +5,7 @@ import cache from '@/utils/cache'; import { load } from 'cheerio'; const apiKey = '0QfOX3Vn51YCzitbLaRkTTBadtWpgTN8NZLW0C1SEM'; +const fetchedArticleContentHtmlImgRegex = //; export const route: Route = { path: '/:market/:name/:id', @@ -54,10 +55,11 @@ export const route: Route = { let articleId = parsedArticleUrl?.pathname.split('/').pop(); if (articleId?.startsWith('ar-')) { articleId = articleId.substring(3); - const fetchedArticleContentHtml = (await cache.tryGet(articleId, async () => { + let fetchedArticleContentHtml = (await cache.tryGet(articleId, async () => { const articleData = await ofetch(`https://assets.msn.com/content/view/v2/Detail/${market}/${articleId}`); return articleData.body; - })) as string; // cache article content for 3 months + })) as string; + fetchedArticleContentHtml = fetchedArticleContentHtml.replace(fetchedArticleContentHtmlImgRegex, ''); articleContentHtml = fetchedArticleContentHtml; } From 2a8db5a046075935f8d8145dfe448fba7d249c6b Mon Sep 17 00:00:00 2001 From: KTachibanaM Date: Fri, 3 Jan 2025 01:47:21 +0000 Subject: [PATCH 2/2] feat(route): fix images not displaying in msn news full text --- lib/routes/msn/index.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/routes/msn/index.ts b/lib/routes/msn/index.ts index 216cc52312e30c..aff863e1330fe9 100644 --- a/lib/routes/msn/index.ts +++ b/lib/routes/msn/index.ts @@ -55,12 +55,11 @@ export const route: Route = { let articleId = parsedArticleUrl?.pathname.split('/').pop(); if (articleId?.startsWith('ar-')) { articleId = articleId.substring(3); - let fetchedArticleContentHtml = (await cache.tryGet(articleId, async () => { + const fetchedArticleContentHtml = (await cache.tryGet(articleId, async () => { const articleData = await ofetch(`https://assets.msn.com/content/view/v2/Detail/${market}/${articleId}`); return articleData.body; })) as string; - fetchedArticleContentHtml = fetchedArticleContentHtml.replace(fetchedArticleContentHtmlImgRegex, ''); - articleContentHtml = fetchedArticleContentHtml; + articleContentHtml = fetchedArticleContentHtml.replace(fetchedArticleContentHtmlImgRegex, ''); } return {