From d91a0ab9c727f8c7d5244ef3ea3dbe732b2889ff Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Mon, 23 Dec 2019 15:18:32 +0000 Subject: [PATCH] typeahead: Remove diacritics on full names, not pieces. This may actually be a slowdown for the worst case scenario, but it sets us up to be able to easily short circuit the removal of diacritic characters for users that have pure ascii names. For example, czo has lots of names like this: - Tim Abbott - Steve Howell Since they're pure ascii, we can do a one-time check. A subsequent commit will show how we use this. --- static/js/people.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/static/js/people.js b/static/js/people.js index 8cf04368f6..cef2c70629 100644 --- a/static/js/people.js +++ b/static/js/people.js @@ -770,12 +770,15 @@ exports.build_termlet_matcher = function (termlet) { const is_ascii = /^[a-z]+$/.test(termlet); - return function (names) { + return function (user) { + let full_name = user.full_name; + if (is_ascii) { + // Only ignore diacritics if the query is plain ascii + full_name = exports.remove_diacritics(full_name); + } + const names = full_name.toLowerCase().split(' '); + return _.any(names, function (name) { - if (is_ascii) { - // Only ignore diacritics if the query is plain ascii - name = exports.remove_diacritics(name); - } if (name.indexOf(termlet) === 0) { return true; } @@ -796,9 +799,8 @@ exports.build_person_matcher = function (query) { return true; } - const names = user.full_name.toLowerCase().split(' '); return _.all(termlet_matchers, function (matcher) { - return matcher(names); + return matcher(user); }); }; };