mediawiki.api: Don't apply file extension stripping to category names
`mw.Title#getNameText()` strips anything following a dot (.), assuming
it's a file name (which doesn't make sense for category names).
C.f. https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.Title-method-getMainText
This causes some trouble in UploadWizard's category-suggestion system.
This bug has been there since the very first version (cb0cf72eba)
which, ironically, was specifically written for UploadWizard.
Bug: 64764
Change-Id: I2925e1050215272cdf03c8c6b1de6ba79348f6a5
This commit is contained in:
parent
9db61c9ab5
commit
4ffb4cf0b0
3 changed files with 33 additions and 1 deletions
|
|
@ -73,7 +73,7 @@
|
|||
var texts = [];
|
||||
if ( data.query && data.query.allpages ) {
|
||||
$.each( data.query.allpages, function ( i, category ) {
|
||||
texts.push( new mw.Title( category.title ).getNameText() );
|
||||
texts.push( new mw.Title( category.title ).getMainText() );
|
||||
} );
|
||||
}
|
||||
return texts;
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ return array(
|
|||
'tests/qunit/suites/resources/mediawiki/mediawiki.user.test.js',
|
||||
'tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js',
|
||||
'tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js',
|
||||
'tests/qunit/suites/resources/mediawiki.api/mediawiki.api.category.test.js',
|
||||
'tests/qunit/suites/resources/mediawiki.api/mediawiki.api.parse.test.js',
|
||||
'tests/qunit/suites/resources/mediawiki.api/mediawiki.api.watch.test.js',
|
||||
'tests/qunit/suites/resources/mediawiki.special/mediawiki.special.recentchanges.test.js',
|
||||
|
|
@ -96,6 +97,7 @@ return array(
|
|||
'jquery.tablesorter',
|
||||
'jquery.textSelection',
|
||||
'mediawiki.api',
|
||||
'mediawiki.api.category',
|
||||
'mediawiki.api.parse',
|
||||
'mediawiki.api.watch',
|
||||
'mediawiki.jqueryMsg',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
( function ( mw ) {
|
||||
QUnit.module( 'mediawiki.api.category', QUnit.newMwEnvironment( {
|
||||
setup: function () {
|
||||
this.server = this.sandbox.useFakeServer();
|
||||
}
|
||||
} ) );
|
||||
|
||||
QUnit.test( '.getCategoriesByPrefix()', function ( assert ) {
|
||||
QUnit.expect( 1 );
|
||||
|
||||
var api = new mw.Api();
|
||||
|
||||
api.getCategoriesByPrefix( 'Foo' ).done( function ( matches ) {
|
||||
assert.deepEqual(
|
||||
matches,
|
||||
[ 'Food', 'Fool Supermarine S.6', 'Fools' ]
|
||||
);
|
||||
} );
|
||||
|
||||
this.server.respond( function ( req ) {
|
||||
req.respond( 200, { 'Content-Type': 'application/json' },
|
||||
'{ "query": { "allpages": [ ' +
|
||||
'{ "title": "Category:Food" },' +
|
||||
'{ "title": "Category:Fool Supermarine S.6" },' +
|
||||
'{ "title": "Category:Fools" }' +
|
||||
'] } }'
|
||||
);
|
||||
} );
|
||||
} );
|
||||
}( mediaWiki ) );
|
||||
Loading…
Reference in a new issue