2022-02-04 03:04:56 +00:00
|
|
|
export const cleanUsername = (name: string, maxLength = 25) => {
|
|
|
|
return name
|
|
|
|
.replace(/\s+/g, '')
|
|
|
|
.normalize('NFD') // split an accented letter in the base letter and the acent
|
|
|
|
.replace(/[\u0300-\u036f]/g, '') // remove all previously split accents
|
|
|
|
.replace(/[^A-Za-z0-9_]/g, '') // remove all chars not letters, numbers and underscores
|
|
|
|
.substring(0, maxLength)
|
|
|
|
}
|
|
|
|
|
2022-06-18 21:31:39 +00:00
|
|
|
export const cleanDisplayName = (displayName: string, maxLength = 30) => {
|
2022-02-04 03:04:56 +00:00
|
|
|
return displayName.replace(/\s+/g, ' ').substring(0, maxLength).trim()
|
|
|
|
}
|