Last modified: 2009-07-09 05:12:07 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T20889, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 18889 - External links should skip the scheme if it's the same as the site
External links should skip the scheme if it's the same as the site
Status: RESOLVED INVALID
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
unspecified
All All
: Low enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-05-24 06:19 UTC by Laurence 'GreenReaper' Parry
Modified: 2009-07-09 05:12 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Hack to remove http: from links (not safe for other protocols, see comment) (671 bytes, patch)
2009-07-09 05:12 UTC, Laurence 'GreenReaper' Parry
Details

Description Laurence 'GreenReaper' Parry 2009-05-24 06:19:56 UTC
Each external or interwiki* link to a standard web site on a MediaWiki wiki has the scheme/protocol http: at the front of the href and link title. This is not necessary when the wiki is already at a http: URL.

Links like //www.example.com/ are perfectly valid and point to http://www.example.com/ in this context, just as a link to /wiki/Something is valid and unique on http://en.wikipedia.org/

If we remove the scheme from the emitted XHTML if identical to that of the site, ten bytes could be saved on each link. This would add up even if the site is gzipped; sadly, many - including Wikipedia's own front page; see bug 15944 - are not. On the current wikipedia.org it would save 1685 bytes, or 3%; if gzipped, it would save 59 bytes, or 0.4%. Still not bad for free!

It is not possible to specify a URL like [//example.com/ this] in the wikitext itself, either, but this is probably not a bad thing, as links should point to the same site when copied to another wiki.

* It will be possible to specify interwiki links without schemes once bug 18664 is fixed, and it might be necessary to modify the same code when fixing this one.
Comment 1 Dan Jacobson 2009-05-25 21:35:34 UTC
I notice {{SERVER}} , {{fullurl:ZZZZZ}} don't make smarter links (href="/" and href="/wiki/ZZZZZ") either.

Too bad we can't fix most of bug 18274 at the same time.
Comment 2 Brion Vibber 2009-05-26 22:00:28 UTC
I'm going to have to say no to this, as there's a possible plan afoot to improve our cache locality by using protocol-relative links for site-local links allowing us to use the same cached HTML entries for SSL and non-SSL access.

In this case, we wouldn't be able to guarantee that other links would be consistent and functional; the savings of a few characters per link is fairly small versus the liklihood of breakage.
Comment 3 Laurence 'GreenReaper' Parry 2009-05-26 22:24:19 UTC
Unless I'm misunderstanding you, the problem you applies only to sites accessible by more than one protocol, which is a rather small proportion of MediaWiki sites.

I can understand this being at a low priority (and not something you want to work on) if Wikipedia has to keep it turned off, but I don't think it makes the idea invalid. If I get time, I'll see about making a patch for it.
Comment 4 Brion Vibber 2009-05-27 17:15:26 UTC
Patch won't be accepted as it has no functional purpose and would interfere with production use, but feel free to post it if you like.
Comment 5 Laurence 'GreenReaper' Parry 2009-07-09 05:12:07 UTC
Created attachment 6313 [details]
Hack to remove http: from links (not safe for other protocols, see comment)

Seeing as this is not likely to get in, I'll just throw out what we're using at wikifur.com. Potential reusers should bear in mind that makeExternalLink is called from several other places, and the result of suddenly giving these callers a protocol-less link is undefined and untested. You have been warned! :-)

I figure almost all sites using this will be using http:. A more general patch would support https: as well, perhaps by taking $wgServer and finding the position of the colon, then comparing that and the preceding string against $url.

For bonus marks, consider removing http: from your interwiki table entries as well to cut protocols from your language and Wikipedia: links (phpMyAdmin + SQL export with drop table option + find+replace 687474703a2f2f with 2f2f [or http:// with //] + SQL reimport, requires patches for bug 18664 and bug 19270)

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links