diff --git a/app/assets/javascripts/admin/addon/controllers/admin-site-settings.js b/app/assets/javascripts/admin/addon/controllers/admin-site-settings.js index b6a1dedfaa6..239ea408124 100644 --- a/app/assets/javascripts/admin/addon/controllers/admin-site-settings.js +++ b/app/assets/javascripts/admin/addon/controllers/admin-site-settings.js @@ -79,7 +79,15 @@ export default class AdminSiteSettingsController extends Controller { item.get("description").toLowerCase().includes(filter) || (item.get("value") || "").toString().toLowerCase().includes(filter); if (!filterResult && fuzzyRegex && fuzzyRegex.test(setting)) { - fuzzyMatches.push(item); + // Tightens up fuzzy search results a bit. + const fuzzySearchLimiter = 15; + const strippedSetting = setting.replace(/[^a-z0-9]/gi, ""); + if ( + strippedSetting.length <= + strippedQuery.length + fuzzySearchLimiter + ) { + fuzzyMatches.push(item); + } } return filterResult; } else { diff --git a/app/assets/javascripts/discourse/tests/unit/controllers/admin-site-settings-test.js b/app/assets/javascripts/discourse/tests/unit/controllers/admin-site-settings-test.js index f4f7c159884..d89b7a6ce41 100644 --- a/app/assets/javascripts/discourse/tests/unit/controllers/admin-site-settings-test.js +++ b/app/assets/javascripts/discourse/tests/unit/controllers/admin-site-settings-test.js @@ -30,6 +30,16 @@ module("Unit | Controller | admin-site-settings", function (hooks) { value: "", setting: "hello world", }), + SiteSetting.create({ + description: "", + value: "", + setting: "digest_logo", + }), + SiteSetting.create({ + description: "", + value: "", + setting: "pending_users_reminder_delay_minutes", + }), ], }, ]; @@ -38,5 +48,8 @@ module("Unit | Controller | admin-site-settings", function (hooks) { assert.deepEqual(results[0].siteSettings.length, 2); // ensures hello world shows up before fuzzy hpello world assert.deepEqual(results[0].siteSettings[0].setting, "hello world"); + results = controller.performSearch("digest", settings2); + assert.deepEqual(results[0].siteSettings.length, 1); + assert.deepEqual(results[0].siteSettings[0].setting, "digest_logo"); }); });