https://www.mediawiki.org/wiki/Special:Code/MediaWiki/110826
Revision: 110826
Author: bawolff
Date: 2012-02-07 08:48:38 +0000 (Tue, 07 Feb 2012)
Log Message:
-----------
(bug 33551) - Make ShortUrl work properly with protocol relative urls.
Modified Paths:
--------------
trunk/extensions/ShortUrl/ShortUrl.php
trunk/extensions/ShortUrl/js/ext.shortUrl.js
Modified: trunk/extensions/ShortUrl/ShortUrl.php
===================================================================
--- trunk/extensions/ShortUrl/ShortUrl.php 2012-02-07 08:07:28 UTC (rev
110825)
+++ trunk/extensions/ShortUrl/ShortUrl.php 2012-02-07 08:48:38 UTC (rev
110826)
@@ -18,9 +18,11 @@
/**
* Configuration variables
* Prefix to use for the shortened URL. mod_rewrite (or equivalent) needs to
be setup
- * to produce a shorter URL
+ * to produce a shorter URL. See example redirect.htaccess file.
* Default is false which just uses the (not so short) URL that all Special
Pages get
* Eg:
http://en.wikipedia.org/wiki/Special:ShortUrl/5234
+ * An example value for this variable might be:
+ * $wgShortUrlPrefix = '//en.wikipedia.org/r/';
*/
$wgShortUrlPrefix = false;
@@ -53,5 +55,6 @@
'scripts' => 'js/ext.shortUrl.js',
'styles' => 'css/ext.shortUrl.css',
'localBasePath' => dirname( __FILE__ ),
- 'remoteExtPath' => 'ShortUrl'
+ 'remoteExtPath' => 'ShortUrl',
+ 'dependencies' => array( 'mediawiki.Uri' ),
);
Modified: trunk/extensions/ShortUrl/js/ext.shortUrl.js
===================================================================
--- trunk/extensions/ShortUrl/js/ext.shortUrl.js 2012-02-07 08:07:28 UTC
(rev 110825)
+++ trunk/extensions/ShortUrl/js/ext.shortUrl.js 2012-02-07 08:48:38 UTC
(rev 110826)
@@ -1,6 +1,15 @@
jQuery( function( $ ) {
if( $( '#t-shorturl' ).length ) {
var url = $( '#t-shorturl a' ).attr( 'href' );
- $( '#firstHeading' ).append( $( '<div
class="title-shortlink-container"></div>').append( $( '<a>' ).addClass(
'title-shortlink' ).attr( 'href', url ).text( url ) ) );
+ /* Add protocol for proto-relative urls */
+ var protoNonRelative = ( new mw.Uri( url ) ).toString();
+ $( '#firstHeading' ).append(
+ $( '<div class="title-shortlink-container"></div>')
+ .append( $( '<a>' )
+ .addClass( 'title-shortlink' )
+ .attr( 'href', url )
+ .text( protoNonRelative )
+ )
+ );
}
});
_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@xxxxxxxxxxxxxxxxxxx
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs