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.