Compare commits

...

1 Commits

Author SHA1 Message Date
Vlad Piersec 003eff1d60 fix(Avatar): Fix initials when avatar contains multiple special characters 2021-11-26 10:14:20 +02:00
1 changed files with 2 additions and 2 deletions

View File

@ -14,7 +14,7 @@ const AVATAR_COLORS = [
'#2AA076',
'#00A8B3'
];
const wordSplitRegex = (/\s+|\.+|_+|;+|-+|,+|\|+|\/+|\\+/);
const wordSplitRegex = (/\s+|\.+|_+|;+|-+|,+|\|+|\/+|\\+|"+|'+|\(+|\)+|#+|&+/);
const splitter = new GraphemeSplitter();
/**
@ -66,7 +66,7 @@ function getFirstGraphemeUpper(word) {
export function getInitials(s: ?string) {
// We don't want to use the domain part of an email address, if it is one
const initialsBasis = _.split(s, '@')[0];
const [ firstWord, secondWord ] = initialsBasis.split(wordSplitRegex);
const [ firstWord, secondWord ] = initialsBasis.split(wordSplitRegex).filter(Boolean);
return getFirstGraphemeUpper(firstWord) + getFirstGraphemeUpper(secondWord);
}