Skip to content

Commit

Permalink
fix(android): live reload not working when using adb reverse
Browse files Browse the repository at this point in the history
Co-authored-by: jcesarmobile <jcesarmobile@gmail.com>
  • Loading branch information
elylucas and jcesarmobile committed Mar 4, 2021
1 parent 502a2d1 commit 362f221
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,7 @@ public WebResourceResponse shouldInterceptRequest(WebResourceRequest request) {
return null;
}

if (
isLocalFile(loadingUrl) ||
loadingUrl.getHost().equalsIgnoreCase(bridge.getHost()) ||
(bridge.getServerUrl() == null && !bridge.getAppAllowNavigationMask().matches(loadingUrl.getHost()))
) {
if (isLocalFile(loadingUrl) || isMainUrl(loadingUrl) || !isAllowedUrl(loadingUrl)) {
Logger.debug("Handling local request: " + request.getUrl().toString());
return handleLocalRequest(request, handler);
} else {
Expand All @@ -188,6 +184,14 @@ private boolean isLocalFile(Uri uri) {
return path.startsWith(capacitorContentStart) || path.startsWith(capacitorFileStart);
}

private boolean isMainUrl(Uri loadingUrl) {
return (bridge.getServerUrl() == null && loadingUrl.getHost().equalsIgnoreCase(bridge.getHost()));
}

private boolean isAllowedUrl(Uri loadingUrl) {
return !(bridge.getServerUrl() == null && !bridge.getAppAllowNavigationMask().matches(loadingUrl.getHost()));
}

private WebResourceResponse handleLocalRequest(WebResourceRequest request, PathHandler handler) {
String path = request.getUrl().getPath();

Expand Down

0 comments on commit 362f221

Please sign in to comment.