From a4daf28ca5881e2f99a5e7a00064fc282b0eafbf Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Fri, 11 Oct 2024 12:21:35 +0800 Subject: [PATCH] fix: catch Invalid Date (#17081) --- lib/middleware/template.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/middleware/template.tsx b/lib/middleware/template.tsx index e91084ed3..36dae2e72 100644 --- a/lib/middleware/template.tsx +++ b/lib/middleware/template.tsx @@ -74,8 +74,16 @@ const middleware: MiddlewareHandler = async (ctx, next) => { } if (outputType !== 'rss') { - item.pubDate && (item.pubDate = convertDateToISO8601(item.pubDate) || ''); - item.updated && (item.updated = convertDateToISO8601(item.updated) || ''); + try { + item.pubDate && (item.pubDate = convertDateToISO8601(item.pubDate) || ''); + } catch { + item.pubDate = ''; + } + try { + item.updated && (item.updated = convertDateToISO8601(item.updated) || ''); + } catch { + item.updated = ''; + } } } }