Skip to content

Commit

Permalink
fix(android): avoid crash if server url ends in / (#7426)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile committed May 8, 2024
1 parent 8419a84 commit e8e8bc3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion android/capacitor/src/main/java/com/getcapacitor/Bridge.java
Expand Up @@ -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;
Expand Down

0 comments on commit e8e8bc3

Please sign in to comment.