The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/lib/utils/normalizeUsername.ts

8 lines
428 B

/**
* Strips a leading '@' from a username if present.
*
* Federated usernames (e.g. @john.doe:matrix.org) are stored with a leading '@',
* while local usernames are not. This utility normalises both forms so callers
* that render `@{username}` don't accidentally produce `@@john.doe:matrix.org`.
*/
export const normalizeUsername = (username: string): string => (username.startsWith('@') ? username.slice(1) : username);