You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
displayname disambiguation fixes (#662)
* fix displayname=undefined being disambiguated and strip Zero Width chars * also strip diaritics and whitespace Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
committed by
Luke Barnard
parent
c4fe15400c
commit
7f50dd205f
10
src/utils.js
10
src/utils.js
@@ -662,3 +662,13 @@ module.exports.inherits = function(ctor, superCtor) {
|
||||
module.exports.isNumber = function(value) {
|
||||
return typeof value === 'number' && isFinite(value);
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes zero width chars, diacritics and whitespace from the string
|
||||
* @param {string} str the string to remove hidden characters from
|
||||
* @return {string} a string with the hidden characters removed
|
||||
*/
|
||||
module.exports.removeHiddenChars = function(str) {
|
||||
return str.normalize('NFD').replace(removeHiddenCharsRegex, '');
|
||||
};
|
||||
const removeHiddenCharsRegex = /[\u200B-\u200D\u0300-\u036f\uFEFF\s]/g;
|
||||
|
||||
Reference in New Issue
Block a user