forked from open-webui/open-webui
		
	handle names with trailing whitespace
This commit is contained in:
		
							parent
							
								
									ac470e64e0
								
							
						
					
					
						commit
						4200ad111c
					
				
					 1 changed files with 2 additions and 3 deletions
				
			
		|  | @ -109,9 +109,8 @@ export const generateInitialsImage = (name) => { | ||||||
| 	ctx.font = '40px Helvetica'; | 	ctx.font = '40px Helvetica'; | ||||||
| 	ctx.textAlign = 'center'; | 	ctx.textAlign = 'center'; | ||||||
| 	ctx.textBaseline = 'middle'; | 	ctx.textBaseline = 'middle'; | ||||||
| 	const firstNameInitial = name[0]; | 
 | ||||||
| 	const lastNameInitial = name.lastIndexOf(' ') > -1 ? name[name.lastIndexOf(' ') + 1] : ''; | 	const initials = name.trim().length > 0 ? name[0] + (name.trim().split(' ').length > 1 ? name[name.lastIndexOf(' ') + 1] : '') : ''; | ||||||
| 	const initials = `${firstNameInitial}${lastNameInitial}`.toUpperCase(); |  | ||||||
| 
 | 
 | ||||||
| 	ctx.fillText(initials.toUpperCase(), canvas.width / 2, canvas.height / 2); | 	ctx.fillText(initials.toUpperCase(), canvas.width / 2, canvas.height / 2); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Danny Liu
						Danny Liu