From f8aec9a2ab4efa994cc4ed9efa6a15b50c37d248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E5=88=80=E9=B1=BC?= <102730551+nikoyoke1@users.noreply.github.com> Date: Fri, 27 Sep 2024 11:21:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=85=E4=B8=BAwindows=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E8=BD=AC=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/tools.js b/apps/tools.js index 7eec3a9..9208ee3 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -1432,7 +1432,12 @@ export class tools extends plugin { try { const urlRex = /(?:https?:\/\/)?(www\.|music\.)?youtube\.com\/[A-Za-z\d._?%&+\-=\/#]*/g; const url2Rex = /(?:https?:\/\/)?youtu\.be\/[A-Za-z\d._?%&+\-=\/#]*/g; - let url = urlRex.exec(e.msg)?.[0]?.replace(/&/g, '^&') || url2Rex.exec(e.msg)?.[0]?.replace(/&/g, '^&'); + // 检测操作系统平台 + const isWindows = process.platform === 'win32'; + + // 匹配并转义 URL 中的 & 符号(仅对 Windows 进行转义) + let url = urlRex.exec(e.msg)?.[0]?.replace(/&/g, isWindows ? '^&' : '&') || + url2Rex.exec(e.msg)?.[0]?.replace(/&/g, isWindows ? '^&' : '&'); // 适配 YouTube Music if (url.includes("music")) { // https://music.youtube.com/watch?v=F4sRtMoIgUs&si=7ZYrHjlI3fHAha0F