Add star to template search term only when it's possible

Discussed in T274903#7077957. Note this might not be the
"perfect" solution. We are still experimenting, and this is
all hidden behind a feature flag. This is the change with the
most minimal impact. Actively trimming the input is another
solution, but with a bigger impact we might want to discuss
first.

Bug: T274903
Change-Id: I2ed06c04bb96c7b61bd7e87ad001e639ea6d06a2
This commit is contained in:
Thiemo Kreuz 2021-05-11 15:40:10 +02:00 committed by Thiemo Kreuz (WMDE)
parent 03c277e96a
commit 333cadd5d4

View file

@ -50,7 +50,12 @@ ve.ui.MWTemplateTitleInputWidget.prototype.getApiParams = function ( query ) {
if ( mw.config.get( 'wgVisualEditorConfig' ).cirrusSearchLookup ) {
params.generator = 'search';
params.gsrsearch = params.gpssearch;
// Searching for "foo *" is pointless. Don't normalize it to "foo*" either but leave it
// unchanged. This makes the word "foo" behave the same in "foo " and "foo bar". In both
// cases it's not considered a prefix any more.
if ( !/\s$/.test( params.gsrsearch ) ) {
params.gsrsearch += '*';
}
// params.gsrsort = 'incoming_links_desc';
params.gsrnamespace = params.gpsnamespace;
params.gsrlimit = params.gpslimit;