mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
people: Improve mentioning users with diacritics in their name.
This makes it possible to mention a user with a name like Gaël that contains diacritics by typing e.g. "Gael", significantly reducing the need to use a special keyboard to mention other users. Fixes #11183.
This commit is contained in:
@@ -739,7 +739,7 @@ exports.incr_recipient_count = function (user_id) {
|
||||
|
||||
// Diacritic removal from:
|
||||
// https://stackoverflow.com/questions/18236208/perform-a-find-match-with-javascript-ignoring-special-language-characters-acce
|
||||
function remove_diacritics(s) {
|
||||
exports.remove_diacritics = function (s) {
|
||||
if (/^[a-z]+$/.test(s)) {
|
||||
return s;
|
||||
}
|
||||
@@ -751,7 +751,7 @@ function remove_diacritics(s) {
|
||||
.replace(/[úùüû]/g, "u")
|
||||
.replace(/[ç]/g, "c")
|
||||
.replace(/[ñ]/g, "n");
|
||||
}
|
||||
};
|
||||
|
||||
exports.person_matches_query = function (user, query) {
|
||||
var email = user.email.toLowerCase();
|
||||
@@ -770,7 +770,7 @@ exports.person_matches_query = function (user, query) {
|
||||
return _.any(names, function (name) {
|
||||
if (is_ascii) {
|
||||
// Only ignore diacritics if the query is plain ascii
|
||||
name = remove_diacritics(name);
|
||||
name = exports.remove_diacritics(name);
|
||||
}
|
||||
if (name.indexOf(termlet) === 0) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user