From 1968c9c69d5562cd9742fc7f709080e740cf9cd0 Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 3 Sep 2022 23:41:29 -0500 Subject: [PATCH] autocomplete: lowercase searches clientside. Lowercase searches clientside before sending them to the server. This is to improve cache hit rates when users accidentally type in uppercase, especially on mobile where the first letter often gets capitalized. --- app/javascript/src/javascripts/autocomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/javascript/src/javascripts/autocomplete.js b/app/javascript/src/javascripts/autocomplete.js index c3b9ed615..55ddddbd9 100644 --- a/app/javascript/src/javascripts/autocomplete.js +++ b/app/javascript/src/javascripts/autocomplete.js @@ -97,7 +97,7 @@ Autocomplete.current_term = function($input) { let query = $input.get(0).value; let caret = $input.get(0).selectionStart; let regexp = new RegExp(`^[-~(]*(${Autocomplete.tag_prefixes().join("|")})?`); - let match = query.substring(0, caret).match(/\S*$/)[0].replace(regexp, ""); + let match = query.substring(0, caret).match(/\S*$/)[0].replace(regexp, "").toLowerCase(); return match; };