03f36cf954
* add id, userId to comment * change user info cloud function and script; move cleanUsername to common * change user info script * fix rules * add fund button: useLocation hook * profile page * merge * profile stuff * avatar uploading to storage bucket * changeUserInfo: use transaction * Styles for profile page * Edit mode for profile, and more styles Co-authored-by: James Grugett <jahooma@gmail.com>
13 lines
537 B
TypeScript
13 lines
537 B
TypeScript
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)
|
|
}
|
|
|
|
export const cleanDisplayName = (displayName: string, maxLength = 25) => {
|
|
return displayName.replace(/\s+/g, ' ').substring(0, maxLength).trim()
|
|
}
|