diff --git a/lib/routes/kcna/news.ts b/lib/routes/kcna/news.ts index 9e6a2e773113c8..885c49a1f3d4c3 100644 --- a/lib/routes/kcna/news.ts +++ b/lib/routes/kcna/news.ts @@ -68,12 +68,12 @@ async function handler(ctx) { .map((_, item) => { item = $(item); const dateElem = item.find('.publish-time'); - const dateString = dateElem.text(); + const dateString = dateElem.text().match(/\d+\.\d+\.\d+/); dateElem.remove(); return { title: item.text(), link: rootUrl + item.attr('href'), - pubDate: timezone(parseDate(dateString.match(/\d+\.\d+\.\d+/)[0]), +9), + pubDate: timezone(parseDate(dateString[0]), +9), }; }) .get(); @@ -89,9 +89,9 @@ async function handler(ctx) { item.title = $('article-main-title').text() || item.title; const dateElem = $('.publish-time'); - const dateString = dateElem.text(); + const dateString = dateElem.text().match(/\d+\.\d+\.\d+/)); dateElem.remove(); - item.pubDate = timezone(parseDate(dateString.match(/\d+\.\d+\.\d+/)[0]), +9) || item.pubDate; + item.pubDate = dateString ? timezone(parseDate(dateString[0], +9)) : item.pubDate; const description = fixDesc($, $('.article-content-body .content-wrapper'));