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 authored May 7, 2024
1 parent 5b2ab7c commit f8264cc
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
Original file line number Diff line number Diff line change
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 f8264cc

Please sign in to comment.