Skip to content

Commit

Permalink
Merge pull request #5407 from nextcloud-libraries/fix/nc-avatar-regex
Browse files Browse the repository at this point in the history
fix(NcAvatar): handle regex error on initials match
  • Loading branch information
susnux committed Mar 15, 2024
2 parents 2efe99c + b30389e commit dbc9f05
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/NcAvatar/NcAvatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ export default {
if (this.showInitials) {
const user = this.userIdentifier.trim()
if (user === '') {
return '?'
return initials
}
/**
Expand All @@ -487,7 +487,12 @@ export default {
* \s: White space for breaking the string
* @type {string}
*/
const filtered = user.match(/[\p{L}\p{N}\s]/gu).join('')
const filteredChars = user.match(/[\p{L}\p{N}\s]/gu)
if (filteredChars == null) {
return initials
}
const filtered = filteredChars.join('')
const idx = filtered.lastIndexOf(' ')
initials = String.fromCodePoint(filtered.codePointAt(0))
if (idx !== -1) {
Expand Down

0 comments on commit dbc9f05

Please sign in to comment.