var page, anchor, url, $el;
page = textify( nodes[ 0 ] );
+ // Strip leading ':', which is used to suppress special behavior in wikitext links,
+ // e.g. [[:Category:Foo]] or [[:File:Foo.jpg]]
+ if ( page.charAt( 0 ) === ':' ) {
+ page = page.slice( 1 );
+ }
url = mw.util.getUrl( page );
if ( nodes.length === 1 ) {
process( tasks, QUnit.start );
} );
- QUnit.test( 'Links', 11, function ( assert ) {
+ QUnit.test( 'Links', 14, function ( assert ) {
var testCases,
expectedDisambiguationsText,
expectedMultipleBars,
// Pipe trick is not supported currently, but should not parse as text either.
mw.messages.set( 'pipe-trick', '[[Tampa, Florida|]]' );
+ mw.messages.set( 'reverse-pipe-trick', '[[|Tampa, Florida]]' );
+ mw.messages.set( 'empty-link', '[[]]' );
this.suppressWarnings();
assert.equal(
formatParse( 'pipe-trick' ),
'[[Tampa, Florida|]]',
'Pipe trick should not be parsed.'
);
+ assert.equal(
+ formatParse( 'reverse-pipe-trick' ),
+ '[[|Tampa, Florida]]',
+ 'Reverse pipe trick should not be parsed.'
+ );
+ assert.equal(
+ formatParse( 'empty-link' ),
+ '[[]]',
+ 'Empty link should not be parsed.'
+ );
this.restoreWarnings();
expectedMultipleBars = '<a title="Main Page" href="/wiki/Main_Page">Main|Page</a>';
'Special characters'
);
+ mw.messages.set( 'leading-colon', '[[:File:Foo.jpg]]' );
+ assert.htmlEqual(
+ formatParse( 'leading-colon' ),
+ '<a title="File:Foo.jpg" href="/wiki/File:Foo.jpg">File:Foo.jpg</a>',
+ 'Leading colon in links is stripped'
+ );
+
assert.htmlEqual(
formatParse( 'jquerymsg-test-statistics-users-sitename' ),
expectedListUsersSitename,