From 89e021f52baef89f8f9ce67781033521b0fbfde3 Mon Sep 17 00:00:00 2001 From: kdletters Date: Tue, 1 Sep 2026 20:16:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E9=BD=90=20H5=20=E5=AF=BC=E8=88=AA?= =?UTF-8?q?=E9=9D=99=E6=80=81=E6=96=AD=E8=A8=80=E6=A0=BC=E5=BC=8F=E5=85=BC?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 兼容原生页面 URL 调用对象被格式化拆行 --- scripts/check-native-shells.mjs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/check-native-shells.mjs b/scripts/check-native-shells.mjs index dcc0d25e6..293154ad9 100644 --- a/scripts/check-native-shells.mjs +++ b/scripts/check-native-shells.mjs @@ -3244,17 +3244,20 @@ function assertH5HostBridgePayloadBoundaries() { ); } if ( - !h5HostBridgeSource.includes( + !sourceIncludesSnippet( + h5HostBridgeSource, 'function normalizeNativeAppPageUrl(url: string)', ) || - !h5HostBridgeSource.includes("trimmedUrl.startsWith('//')") || - !h5HostBridgeSource.includes( + !sourceIncludesSnippet(h5HostBridgeSource, "trimmedUrl.startsWith('//')") || + !sourceIncludesSnippet( + h5HostBridgeSource, 'nativePageUrl.origin !== HOST_BRIDGE_PUBLIC_WEB_ORIGIN', ) || - !h5HostBridgeSource.includes( + !sourceIncludesSnippet( + h5HostBridgeSource, 'const normalizedUrl = normalizeNativeAppPageUrl(url);', ) || - !h5HostBridgeSource.includes('{ url: normalizedUrl },') + !sourceIncludesSnippet(h5HostBridgeSource, 'url: normalizedUrl,') ) { throw new Error( 'H5 HostBridge facade must reject unsafe native app navigation targets before sending navigation.openNativePage', @@ -4149,7 +4152,7 @@ function sourceIncludesSnippet(source, snippet) { .replace(/\s+/g, ' ') .replace(/\s*([()[\]{}])\s*/g, '$1') .replace(/\s*,\s*/g, ',') - .replace(/,\)/g, ')') + .replace(/,([)}\]])/g, '$1') .trim(); return source.includes(snippet) || compact(source).includes(compact(snippet)); }