-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Capacitor code not injected to external websites when using * in allowNavigation #1389
Comments
@jcesarmobile I did some tests on the fresh project and here is what I have found (let's use
{
"appId": "com.example.app",
"appName": "App",
"bundledWebRuntime": true,
"webDir": "www",
"server": {
"allowNavigation": [
"www.example.com"
]
}
}
<!DOCTYPE html>
<html>
<head>
<script>
location.href = 'https://www.example.com/test'
</script>
</head>
<body>
</body>
</html> results in Plain |
Makes it possible use star masks in `server.allowNavigation` option of `capacitor.config.json`. Examples: - `*.example.com` would match `app.example.com`, `www.example.com` but not `example.com` - `192.168.*.*` is valid What the changes are: - `HostMask` is a matcher, it parses text into masks and check strings against it `boolean matches(String host)`, i.e. `HostMask.Parser.parse("192.168.*.*).matches("192.168.1.1")` would return `true` - `HostMaskTest` is a test suite for the above, more mask examples are inside - `UriMatcher` was tought to use `HostMask` for the host part - `Bridge` contained some matching of its own, that was replaced with use of `HostMask` Closes #1389
Just wanted to mention that, although the pull-request adding wildcard support is very helpful, there is an edge-case: the URI matcher does not consider the port segment to be a separate segment. Example: For the URI So to match it, you must use What was confusing me is that I tried all of these:
However, these work just fine:
In other words, a "non-wildcard" 4th-digit requires that you enter the port, whereas a "wildcard" 4th-digit requires that you do not enter the port. (which is a bit confusing) Real-world drawback: It forces you to either...
The second is obviously better -- though it is a bit unfortunate that you can't restrict it to a specific port, if using a wildcard for the last ip-address segment. |
For whoever will stumble upon this issue - Capacitor is also not injected if your app uses ServiceWorkers. Solution available in #1655 |
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. |
Description of the problem:
When using * in allowNavigation, the Capacitor javascript is not injected to the external page
Create an app that just redirects to https://www.google.es (or your country one) and add
Check Capacitor object and it won't be there.
Change to
and Capacitor object should be there
Affected platform
OS of the development machine
Other information:
Capacitor version: beta 19
node version:
npm version:
CocoaPods version:
Steps to reproduce:
Link to sample project:
The text was updated successfully, but these errors were encountered: