Skip to content
This repository has been archived by the owner on Jan 12, 2023. It is now read-only.

Commit

Permalink
Prevent onURLChanged() being called with null URL. (#1310)
Browse files Browse the repository at this point in the history
  • Loading branch information
pocmo committed Sep 14, 2017
1 parent 644d0c0 commit 37a08f3
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,14 @@ public WebResourceResponse shouldInterceptRequest(WebView view, final WebResourc
// not have a trailing URL (usually no trailing / when a link is entered via UrlInputFragment),
// hence we do a somewhat convoluted test:
final String requestURL = request.getUrl().toString();
if (UrlUtils.urlsMatchExceptForTrailingSlash(currentPageURL, requestURL)) {
final String currentURL = currentPageURL;

if (UrlUtils.urlsMatchExceptForTrailingSlash(currentURL, requestURL)) {
view.post(new Runnable() {
@Override
public void run() {
if (callback != null) {
callback.onURLChanged(currentPageURL);
callback.onURLChanged(currentURL);
}
}
});
Expand Down Expand Up @@ -208,8 +210,8 @@ public void onPageFinished(WebView view, final String url) {
// The URL which is supplied in onPageFinished() could be fake (see #301), but webview's
// URL is always correct _except_ for error pages
final String viewURL = view.getUrl();
if (!UrlUtils.isInternalErrorURL(viewURL)) {
callback.onURLChanged(view.getUrl());
if (!UrlUtils.isInternalErrorURL(viewURL) && viewURL != null) {
callback.onURLChanged(viewURL);
}
}
super.onPageFinished(view, url);
Expand Down

0 comments on commit 37a08f3

Please sign in to comment.