Skip to content

Commit 0053a6f

Browse files
authored
Fix for unicode regex in ie/firefox (#408)
1 parent 5e3ebd6 commit 0053a6f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/components/mgt-person/mgt-person.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,7 @@ export class MgtPerson extends MgtTemplatedComponent {
585585
if (!initials && person.displayName) {
586586
const name = person.displayName.split(/\s+/);
587587
for (let i = 0; i < 2 && i < name.length; i++) {
588-
if (name[i][0] && name[i][0].match(/\p{L}/gu)) {
589-
// check if letter
588+
if (name[i][0] && this.isLetter(name[i][0])) {
590589
initials += name[i][0].toUpperCase();
591590
}
592591
}
@@ -595,6 +594,14 @@ export class MgtPerson extends MgtTemplatedComponent {
595594
return initials;
596595
}
597596

597+
private isLetter(char: string) {
598+
try {
599+
return char.match(new RegExp('\\p{L}', 'u'));
600+
} catch (e) {
601+
return char.toLowerCase() !== char.toUpperCase();
602+
}
603+
}
604+
598605
private handleMouseClick(e: MouseEvent) {
599606
if (this.personCardInteraction === PersonCardInteraction.click) {
600607
this.showPersonCard();

0 commit comments

Comments
 (0)