fix(search): 🐛 search all content namespaces for Action API

This commit is contained in:
alistair3149 2024-09-27 03:15:55 -04:00
parent ee2310be67
commit 3719897e93
No known key found for this signature in database

View file

@ -3,6 +3,15 @@
const fetchJson = require( '../fetch.js' );
const urlGenerator = require( '../urlGenerator.js' );
// Based on mediawiki.searchSuggest
// eslint-disable-next-line array-callback-return
const searchNS = Object.entries( mw.config.get( 'wgFormattedNamespaces' ) ).map( ( [ nsID ] ) => {
if ( nsID >= 0 && mw.user.options.get( 'searchNs' + nsID ) ) {
// Cast string key to number
return Number( nsID );
}
} ).filter( ( item ) => item !== undefined );
/**
* @typedef {Object} ActionResponse
* @property {ActionQuery[]} query
@ -151,12 +160,14 @@ function mwActionApiSearchClient( config ) {
const descriptionSource = config.wgCitizenSearchDescriptionSource;
const searchApiUrl = config.wgScriptPath + '/api.php';
const params = {
format: 'json',
formatversion: '2',
action: 'query',
smaxage: cacheExpiry,
maxage: cacheExpiry,
namespace: searchNS,
generator: 'prefixsearch',
gpssearch: q,
gpslimit: limit.toString(),