Skip to content

Commit a8b105a

Browse files
[5.2] Remove root path only if it is at the beginning - HtmlHelper
Thanks to @costafrancesco94 and all others involved - great teamwork 💚
1 parent 40a39c4 commit a8b105a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

libraries/src/HTML/HTMLHelper.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,10 @@ protected static function addFileToBuffer($path = '', $ext = '', $debugMode = fa
12221222
*/
12231223
protected static function convertToRelativePath($path)
12241224
{
1225-
$relativeFilePath = Uri::root(true) . str_replace(JPATH_PUBLIC, '', $path);
1225+
// Remove JPATH_PUBLIC only if it is at beginning of full path
1226+
$path = str_starts_with($path, JPATH_PUBLIC) ? substr_replace($path, '', 0, \strlen(JPATH_PUBLIC)) : $path;
1227+
1228+
$relativeFilePath = Uri::root(true) . $path;
12261229

12271230
// On windows devices we need to replace "\" with "/" otherwise some browsers will not load the asset
12281231
return str_replace(DIRECTORY_SEPARATOR, '/', $relativeFilePath);

0 commit comments

Comments
 (0)