Hi,
I'm using the Web Asset Manager to replace the old "addScript" method. The problem is that the WA does not render the file url correctly in call cases.
Tested with the function:
$wa = \Joomla\CMS\Factory::getApplication()->getDocument()->getWebAssetManager();
$wa->registerAndUseScript($name, $url ...)
Url used : /media/com_test/assets/script.js
Expected result (working with addScript) : <script src="/media/com_test/assets/script.js ...
Real result : <script src="//media/com_test/assets/script.js ...
there is an additional slash at the start of the file
If I use a variable in the url, then it works
Url used : /media/com_test/assets/script.js?rev=123
Real result : <script src="/media/com_test/assets/script.js?ver=123 ...
there is no additional slash
This problem occours when you are working in a subfolder and using the multilanguage
Page url : http://localhost/joomlatest/index.php/fr/
Url used : /joomlatest/media/com_test/assets/script.js
Expected result (working with addScript) : <script src="/joomlatest/media/com_test/assets/script.js ...
Real result : <script src="/joomlatest/joomlatest/media/com_test/assets/script.js ...
the root is duplicated
why does the WA add some data to the url passed ? this must not be done. The url must be given by the variable passed to the function, and it must not be altered
Labels |
Removed:
?
|
Labels |
Added:
No Code Attached Yet
|
Build: 5.3.4 as stated in the report :)
It expecting relative path or URL.
Url used : /media/com_test/assets/script.js
This is not URL ;)
I think the code is expecting the path to be without leading slash.
It something with it
joomla-cms/libraries/src/HTML/HTMLHelper.php
Line 391 in b7fee10
I don't use the HTMLHelper, I use the $doc->addScript
the problem is that the way to work has changed.
something works with the $doc->addScript
the same DOES NOT work with the WebAssetManager
It's a fact and it's breaking things
@ced1870 Always a good idea when report an issue: Let us know on which Joomla version you have observed it.