In my WebView-based app, when the app accesses http://mobile.nytimes.com/ my WebViewClient receives 6-7 onPageFinished(), the first 3-4 with WebView.getUrl() returning the original URL (http://mobile.nytimes.com/) but then it returns "data:text/html" for the rest.
Apparently, data:text/html is a valid URI. Also see https://url.spec.whatwg.org/#fetch-scheme .
However, in my code, I need to instantiate a URL from WebView's url like this:
new URL(myWebView.getUrl());
and unfortunately this throws a MalformedURLException when WebView.getUrl() returns 'data:text/html'.
Is there a way to convert the 'data:text/html' string to a valid URL string so that new URL()
will not throw the MalformedURLException?