using addScript or addStyleSheet, or function from template(the same addScript and addStyleSheet in fact) shape5 template, add "/" at the begining if you put a dot first.
in shape5 option in the head or before /body
<script src="./templates/luxon/js/pace.min.js"></script>
==> this path is going to be modified.
<script src="/templates/luxon/js/pace.min.js"></script>
==>it is ok,no change after
or in index.php:
<?php
$doc = JFactory::getDocument();
$doc->addScript("./js/myscript.js");
?>
result : <script src="/./js/myscript.js"></script>
<script src="./js/myscript.js"></script>
<script src="./templates/luxon/js/pace.min.js"></script>
<script src="/./js/myscript.js"></script>
<script src="/./templates/luxon/js/pace.min.js"></script>
notice the "/" added at the begining.
fresh install 3.6.2 or update from 3.6.0 (not sure)
php 7
since joomla update 3.6.1 or 3.6.2 I don't know before it was working whitout any change in the path
tested on 2 servers, same web host 1&1fr
But i do not know if excluding ./ is correct,
because all relative urls must be prefixed, right ?
so this is not a bug, it is intended behaviour ?
Hello ggppdk,
thanks replying,
do you think it is an intended behaviour ? because before 3.6.1 it was not like this.
result of <script src="./js/myscript.js"></script>
was <script src="./js/myscript.js"></script>
,no change, so I don't know if it is normal, intended.
I would like to know if it is normal and if it can be a problem ?
So since this is intended behavior (?)
and since it was like this for years,
and since you had the SEF plugin always enabled (right ?)
my guess either your site software e.g. template has started adding this "./" recently, (even if some other change in J3.6.x has made the software add "./" ? ,then even in this case the URL has not changed: js/myscript.js is same as: ./js/myscript.js )
The URLs of your site must be made relative to joomla base folder,
contact the author of it software
of course someone else may add to this issue, to me it seems that there is no bug
Ok ggppdk so there is no bug and url like this <script src="/./js/myscript.js"></script
is ok, because joomla adds "base prefix"
thanks a lot ggppdk
very nice to you to explain me.
Regards,
Laurent
you are welcome,
i really appreciate when people say thank you for the time ones spends
but i have feeling you have not read my answer, my answer was quite detailed,
and it reflects the time i spent to make it
if you want to discuss the key points of my answer, sure,
i can be wrong, just answer on them with good arguments
and then if you do it people that make decisions here (i do not make any),
i am sorry i could not provide arguments that satisfy you
again you are welcome, thank you
Also it is very easy
to fix your URLs so that they are no longer relative
and make them absolute
then the absolute URLs will not be touched by the SEF plugin
of course you can ask for the awkward indirect exclusion case, that i explained above
(please take time to read me answer like i took time to answer you)
and make an argument that it needs to be added, and convince people that make decisions of it
again you welcome, regards
Also you forget that when SEF is ON you also get into your page:
<base href="http://mydommmm.com/subfolder/" />
So try to guess, what the following do in relation to above base
<script src="/subfolder/./media/jui/js/html5.js"></script>
<script src="./media/jui/js/html5.js"></script>
<script src="media/jui/js/html5.js"></script>
after you find,
it seems to me that there is none
Spoiler tip:
The 1st one will be unaffected by the base tag (i added /subfolder/ to make a point of this you can remove it, from both the base and from the 1st url)
but 2nd and 3rd will be affected by the base
all resulting to the same file
I have some servers and when I said it was not like this before, it was because one on my server which was running joomla 3.6.0 didn't have modified the path, that's why I was asking for this and why I was thinking maybe maybe there is a problem.perhaps a problem with this server
Now I have done a fresh install (3.6.2) on this server and path was modified
yes ok, I understand but what I didn't understand was /./myscript.js now it is ok
I really appreciate your help and your explanation
please see my very last answer because i posted it,
about the same time that you posted yours
Thus best place to make sure that your URL is as desired
I don't know what more to say,
have a good Sunday
everything is ok, have a good Sunday
So can I close this then?
Status | New | ⇒ | Information Required |
if you can explain how such a change will give some benefit, in combination to the BASE tag then please explain how
your decision, probably this can be closed,
since patching SEF plugin to make an exclusion for this type of relative URLs (that start with dot),
is meaningless due the BASE tag (no proof given for some benefit), also why exclude some relative urls on such criteria, SEF plugin is supposed to prefix all relative urls right ?
you can close if you want, because you write is normal and intended url which start by dot are modified, and path like this is normal : <script src="/./js/myscript.js"></script>
You only need to explain how this will behave:
and people will see the bug
<base href="http://mydommmm.com/" />
<script src="/./media/jui/js/html5.js"></script>
<script src="./media/jui/js/html5.js"></script>
<script src="media/jui/js/html5.js"></script>
the 3 lead to the same, the first and the second become the same <script src="/./media/jui/js/html5.js"></script>
with / at the beginning, and the third,no change.
so no problem they lead to the same script.
Closed
These are valid URLs (notice the double dot somewhere among the single dots in the first one)
<script src="/./media/.././media/./././../././././media/jui/js/html5.js"></script>
<script src="/./media/jui/js/html5.js"></script>
both the above point to :
/media/jui/js/html5.js
Then if you consider the BASE tag the following URLs are the same as the above
<script src="./media/jui/js/html5.js"></script>
<script src="media/jui/js/html5.js"></script>
If you would want them to be relative to location of the executed PHP file
You must write your code taking so that it works both with SEF OFF and SEF ON,
considering that a <base> TAG is added to the page when SEF is ON, that points to joomla base URL, so:
e.g. if you have a 3rd party lib JS or some custom JS that you want to load
$lib_path = '/mylibs/select2'; // path relative to joomla root
$lib_uri = JURI::root(true).$lib_path;
JFactory::getDocument()->addScript($lib_uri.'/select2.min.js');
That is the prefixing of the SEF plugin, adding: /joomla_subforder/
All regular expressions in the SEF plugin
do not check for a dot (in the negative lookahead) when trying to find urls inside various TAG attibute values, and if not absolute prefix them with: joomla base
Current regex part
this would fix it: