- // Get the current domain.
- Uri currentUri = Uri.parse(currentUrl);
- String currentDomain = currentUri.getHost();
-
- // Get the resource domain.
- Uri resourceUri = Uri.parse(resourceUrl);
- String resourceDomain = resourceUri.getHost();
-
- // Initialize the third-party request tracker.
- boolean thirdPartyRequest = false;
-
- // If one of the domains is `about:blank` it will throw a null object reference on the string comparison.
- if ((currentDomain != null) && (resourceDomain != null)) {
- thirdPartyRequest = !resourceDomain.equals(currentDomain);
+ // Assert that currentDomain != null only if this is a third party request. Apparently, lint can't tell that this isn't redundant.
+ //noinspection RedundantIfStatement
+ if (isThirdPartyRequest) {
+ assert currentDomain != null;