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)); }