You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I run capacitor with a server.url that includes a url fragment (https://example.com#foo) on an API 34 Android emulator (or any emulator that supports WebViewFeature.DOCUMENT_START_SCRIPT), Capacitor detects the runtime as web. I can open the WebView in the Chrome Inspector, and run the following in the console:
> Capacitor.platform
<- 'web'
If I remove the fragment from the server.url (https://example.com), then everything works fine. I can open the WebView in the Chrome Inspector, and run the following in the console:
> Capacitor.platform
<- 'android'
Expected Behavior
When I run capacitor with a server.url that includes a url fragment (https://example.com#foo) on an API 34 Android emulator (or any emulator that supports WebViewFeature.DOCUMENT_START_SCRIPT), Capacitor detects the runtime as android, and all plugins work normally.
main shows a server.url without a fragment and things working normally
server_url_fragment_demo shows a server.url with a fragment and only a / path, which demonstrates the bug on if (appUri.getPath().equals("/")) { path of Bridge.java
server_url_fragment_demo_2 shows a server.url with a fragment and a non-/ path, which demonstrates the bug on the else (appUri.getPath().equals("/")) { path of Bridge.java
Additional Information
#7454 is related because it involves allowedOrigin rules.
This bug is worse when server.url contains a path (https://example.com/#foo) or a port (https://example.com:8443#foo) because addDocumentStartJavaScript throws an exception in those cases.
The text was updated successfully, but these errors were encountered:
This issue has been labeled as type: bug. This label is added to issues that that have been reproduced and are being tracked in our internal issue tracker.
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.
Capacitor Version
Other API Details
Platforms Affected
Current Behavior
When I run capacitor with a
server.url
that includes a url fragment (https://example.com#foo
) on an API 34 Android emulator (or any emulator that supportsWebViewFeature.DOCUMENT_START_SCRIPT
), Capacitor detects the runtime asweb
. I can open theWebView
in the Chrome Inspector, and run the following in the console:If I remove the fragment from the
server.url
(https://example.com
), then everything works fine. I can open theWebView
in the Chrome Inspector, and run the following in the console:Expected Behavior
When I run capacitor with a
server.url
that includes a url fragment (https://example.com#foo
) on an API 34 Android emulator (or any emulator that supportsWebViewFeature.DOCUMENT_START_SCRIPT
), Capacitor detects the runtime asandroid
, and all plugins work normally.Project Reproduction
https://github.com/hbordersTwitch/capacitor-server-url-fragment-bug
server.url
without a fragment and things working normallyserver.url
with a fragment and only a/
path, which demonstrates the bug onif (appUri.getPath().equals("/")) {
path of Bridge.javaserver.url
with a fragment and a non-/
path, which demonstrates the bug on theelse (appUri.getPath().equals("/")) {
path of Bridge.javaAdditional Information
#7454 is related because it involves
allowedOrigin
rules.This bug is worse when
server.url
contains a path (https://example.com/#foo
) or a port (https://example.com:8443#foo
) because addDocumentStartJavaScript throws an exception in those cases.The text was updated successfully, but these errors were encountered: