Replies: 1 comment
-
|
Your local fix looks reasonable to me. From the behavior you described, the real problem seems to be that So I’d say the important distinction is:
Because of that, checking for a file extension before appending Honestly, I’d prefer something very close to what you already did: function slashUrl($url)
{
$stripped = rtrim($url, '/');
if (preg_match('/\.[a-zA-Z0-9]{1,5}$/', $stripped)) {
return $stripped;
}
return $stripped . '/';
}The only thing I’d maybe think about is whether you want this to apply only to internal menu links or more generally anywhere So short version:
But conceptually, yes — file-like URLs should probly be exempt from forced trailing slashes. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have some code that is in a sub directory off the main site. https://site.com
so I added a menu option to call it https://site.com/mysite/work.html
it failed because it added a trailing "/" https://site.com/mysite/work.html/
and so the URL with a trailing slash is not a file and as such /mysite/work.html/ is passed as a post value.
I fixed it locally by editing the slashUrl function in system/includes/functions.php
and adding a check for file extension
is there a better way, that I missed?
Beta Was this translation helpful? Give feedback.
All reactions