|
@@ -801,10 +801,23 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
|
801
|
801
|
|
802
|
802
|
@Override
|
803
|
803
|
public void onReceivedSslError(final WebView webView, final SslErrorHandler handler, final SslError error) {
|
|
804
|
+ // WebView.getUrl() will return the top-level window URL.
|
|
805
|
+ // If a top-level navigation triggers this error handler, the top-level URL will be the failing URL (not the current URL).
|
|
806
|
+ // This is desired behavior. We later use these values to determine whether the request is a top-level navigation or a subresource request.
|
|
807
|
+ String topWindowUrl = webView.getUrl();
|
|
808
|
+ String failingUrl = error.getUrl();
|
|
809
|
+
|
|
810
|
+ // Cancel request after obtaining top-level URL.
|
|
811
|
+ // If request is cancelled before obtaining top-level URL, undesired behavior may occur.
|
|
812
|
+ // Undesired behavior: Return value of WebView.getUrl() may be the current URL instead of the failing URL.
|
804
|
813
|
handler.cancel();
|
805
|
814
|
|
|
815
|
+ if (!topWindowUrl.equalsIgnoreCase(failingUrl)) {
|
|
816
|
+ // If error is not due to top-level navigation, then do not call onReceivedError()
|
|
817
|
+ return;
|
|
818
|
+ }
|
|
819
|
+
|
806
|
820
|
int code = error.getPrimaryError();
|
807
|
|
- String failingUrl = error.getUrl();
|
808
|
821
|
String description = "";
|
809
|
822
|
String descriptionPrefix = "SSL error: ";
|
810
|
823
|
|