diff --git a/android/capacitor/src/main/java/com/getcapacitor/Bridge.java b/android/capacitor/src/main/java/com/getcapacitor/Bridge.java index 506477b53..163b1d66d 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/Bridge.java +++ b/android/capacitor/src/main/java/com/getcapacitor/Bridge.java @@ -257,7 +257,11 @@ private void loadWebView() { String allowedOrigin = appUrl; Uri appUri = Uri.parse(appUrl); if (appUri.getPath() != null) { - allowedOrigin = appUri.toString().replace(appUri.getPath(), ""); + if (appUri.getPath().equals("/")) { + allowedOrigin = appUrl.substring(0, appUrl.length() - 1); + } else { + allowedOrigin = appUri.toString().replace(appUri.getPath(), ""); + } } WebViewCompat.addDocumentStartJavaScript(webView, injector.getScriptString(), Collections.singleton(allowedOrigin)); injector = null;