-
Notifications
You must be signed in to change notification settings - Fork 24
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
Invalid handling of non-root home url #199
Comments
Thanks for your thorough report! I've investigated the issue, and the actual issue was that the API client would always use the hosted domain stored in the DB, resulting in the API token invalid error message. In this commit any submitted options in POST are grabbed when get_settings() is called. Also, Plausible has supported domain names with a subdirectory structure (i.e. multilingual sites) for a while now. So parsing just the hostname is no longer needed. |
At this moment plugin incorrectly handles domain name extraction in case a non-root path is used as a home.
\Plausible\Analytics\WP\Helpers::get_domain()
for some reason tries to use a regular expression instead of using the standardparse_url()
function:wordpress/src/Helpers.php
Line 261 in 18bc986
Regular expression completely ignores the fact that there may be something after the domain name itself, effectively generating the wrong result. The most common scenario is use of the multilanguage plugins like WPML, see #160 for examples.
Since Plausible analytics strictly expects hostname for the domain name it is currently not possible to use Plausible analytics for multilingual sites. Any registration attempt results in "Oops! The API token you used is invalid" notification and attempt to use "create an API token" link causes issue because it takes invalid URL for Plausible because the value for domain is taken from the form.
Correct implementation would be:
The text was updated successfully, but these errors were encountered: