From e96b7d2b208f55ef7d362cae3f4cd7e393da2d79 Mon Sep 17 00:00:00 2001 From: tlyong1992 <573865178@qq.com> Date: Sun, 27 Jul 2025 21:01:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9B=BE=E7=89=87=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E5=AF=BC=E8=87=B4=E7=AB=99=E7=82=B9=E5=B4=A9=E6=BA=83?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/notion/mapImage.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/notion/mapImage.js b/lib/notion/mapImage.js index 85ed4e30..bd816954 100644 --- a/lib/notion/mapImage.js +++ b/lib/notion/mapImage.js @@ -119,10 +119,19 @@ const compressImage = (image, width, quality = 50, fmt = 'webp') => { width = siteConfig('IMAGE_COMPRESS_WIDTH') } - // 将URL解析为一个对象 - const urlObj = new URL(image) - // 获取URL参数 - const params = new URLSearchParams(urlObj.search) + + let urlObj + let params + try { + // 将URL解析为一个对象 + urlObj = new URL(image) + // 获取URL参数 + params = new URLSearchParams(urlObj.search) + } catch (err) { + // 捕获异常并打印错误的url + console.error('compressImage: Invalid URL:', image, err) + return image + } // Notion图床 if (