Page MenuHomePhabricator

Don't prefix wgServer in mw.util.wikiGetlink
Closed, ResolvedPublic

Description

Enhanced version

Sometimes it is needed to create local links in a wiki and with the current implementation of mw.util.wikiGetlink, the url includes the server name. Consequently, the CSS matched by

div#content a[href ^="https://"] {...}

will add the lock icon[1] on links whose href is defined by the function (for an example, see the above url).

It would be useful to be able to specify whether the link should be local or not. In the attached file there is an example of how this could be done.

[1] https://secure.wikimedia.org/skins-1.17/vector/images/lock-icon.png


Version: 1.18.x
Severity: enhancement
URL: https://secure.wikimedia.org/wikibooks/pt/wiki/Predefini%C3%A7%C3%A3o:Lista_de_cap%C3%ADtulos/Otimiza%C3%A7%C3%A3o

attachment wikiGetlink (enhanced).js ignored as obsolete

Details

Reference
bz27916

Event Timeline

bzimport raised the priority of this task from to High.Nov 21 2014, 11:24 PM
bzimport set Reference to bz27916.

Some browsers (IE if I recall correctly) internally interpret href attributes absolutely.

Meaning (atleast with javascript selectors) that href^="http" would match internal links as well.
I don't know if this is the case for real CSS as well, should be easy to test.

However, what about removing wgServer prefix all together ? Do we need it ?

Patch by mybugs.mail@gmail.com

make patch from attachment

Attached:

Created attachment 8478
Remove the check and the wgServer prefix from mw.util.wikiGetlink

The check is not needed, if wgArticlePath is undefined there's probably a much bigger issue.

The wgServer doesn't need to be prefixed to the link (if someone really needs it (ie. external tools using the script and somehow defining wgServer in mw.config) they can surely prefix wgServer themselfs.

In most if not all cases this is used to create anchor tags, which are interprated by browsers relatively to the current window location and in some browsers it even auto-prefixes the current environment when setting the href/src attribute.

Attached: