Background of the issue:
I am trying to convert URLs using the WPML plugin, specifically in the file sitepress-multilingual-cmsclassesurl-handlingconverterstrategyclass-wpml-url-converter-domain-strategy.php. The code snippet involved is:
<code>
public function convert_url_string( $source_url, $lang ) {
$original_source_url = untrailingslashit( $source_url );
if ( is_admin() && $this->get_url_helper()->is_url_admin( $original_source_url ) ) {
return $original_source_url;
}
Symptoms:
The untrailingslashit function causes URL conversion of URLs without a trailing slash to include a trailing slash when converted, which is incorrect. I expected no trailing slash when the source URL does not contain one, but instead, I got a trailing slash.
Questions:
Why does the URL conversion add a trailing slash when it shouldn't?
How can I prevent the trailing slash from being added during URL conversion?
Thank you for reaching out to WPML support. I'd be happy to assist you with this issue.
To address your questions accurately, I’ll need to escalate this to our 2nd-tier team. However, before doing so, could you provide a few examples of pages where you're encountering this issue or any steps to reproduce the error. This will help us better understand the behavior and proceed accordingly.
I asked our 2nd tiers about the issue and they mentioned the following:
[php]
Permalinks returned are based on the permalink settings - if the value is /%postname%/ then you will got a trailing slash. if this is without trailing slash, you will receive it without the slash.
I believe you specified the request URI as /some-invalid-url to demonstrate how the system handles invalid or unexpected requests.
If you’re looking to retrieve results regardless of the permalink settings, please let me know. I can escalate your request to our second-tier team for further assistance.
Looking forward to your response.
Best regards
The topic ‘[Closed] URL conversion incorrectly adds trailing slash’ is closed to new replies.
Manage Cookie Consent
We use cookies to optimize our website and services. Your consent allows us to process data such as browsing behavior. Not consenting may affect some features.
Functional
Always active
Required for our website to operate and communicate correctly.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
We use these to analyze the statistics of our site. Collected information is completely anonymous.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
These cookies track your browsing to provide ads relevant to you.