补齐 H5 导航静态断言格式兼容

兼容原生页面 URL 调用对象被格式化拆行
This commit is contained in:
2026-09-01 20:16:50 +08:00
parent 3e8e238286
commit 89e021f52b
+9 -6
View File
@@ -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));
}