Skip to content

Commit

Permalink
fix(name): use first character as fallback for non-ASCII case
Browse files Browse the repository at this point in the history
  • Loading branch information
pd4d10 committed Apr 2, 2018
1 parent d6eb15d commit 5b32259
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/module/component/avatar.component.ts
Expand Up @@ -86,8 +86,12 @@ export class AvatarComponent implements OnInit, OnChanges {
getLetter(): void {
if (this.name && this.name.length) {
const nameInitials = this.name.match(/\b(\w)/g);
const nameLetters = nameInitials.slice(0, 3).join('');
this.letter = nameLetters.toUpperCase();
if (nameInitials) {
const nameLetters = nameInitials.slice(0, 3).join('');
this.letter = nameLetters.toUpperCase();
} else {
this.letter = this.name[0]
}
} else if (this.email && this.email.length) {
const emailInitials = this.email.split('@')[0].match(/\b(\w)/g);
const emailLetters = emailInitials.slice(0, 3).join('');
Expand Down

0 comments on commit 5b32259

Please sign in to comment.