mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-09 22:35:56 +05:45
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>
20 lines
621 B
Swift
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
|
|
}
|
|
|
|
}
|