Files
Antonio PallaresandCursor ddefdd0596 Move the shared web view code out of the paywall component folder (#7598)
WebViewOrigin and the navigation-response status check are not specific to the
web_view component, and already had a caller outside Components in
Cache/WebBundlePrewarmer. Put them in RevenueCatUI/WebView/ so a second web view
can use them without reaching into the paywall component tree.

WebViewNavigationPolicy becomes WebViewComponentNavigationPolicy, since it is
now one of two policies and governs only the component.

Moves and a rename, no behaviour change.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-03 13:38:13 +02:00

20 lines
621 B
Swift

//
// Copyright RevenueCat Inc. All Rights Reserved.
//
// WebViewHTTPStatus.swift
//
import Foundation
enum WebViewHTTPStatus {
// WebKit treats an HTTP 4xx/5xx as a *successful* navigation (the error body renders and `didFail*`
// never fires), so a navigation response's status code is the only signal that the main document
// actually failed to load. Sub-frame/sub-resource errors are ignored so a single failing asset
// doesn't tear down the whole web view.
static func isTerminalError(statusCode: Int, isMainFrame: Bool) -> Bool {
return isMainFrame && statusCode >= 400
}
}