mirror of
https://gh.wpcy.net/https://github.com/elementor/one-click-accessibility.git
synced 2026-04-21 07:09:20 +08:00
* add: plan name and subscription link * update: refactor my account menu * update: move truncate email to a helper file * update: simplify truncation logic
17 lines
447 B
JavaScript
17 lines
447 B
JavaScript
/**
|
|
* Truncate email address if it exceeds the maximum length.
|
|
* @param {string} email Email address
|
|
* @param {number} maxLength Maximum length of the email address
|
|
* @return {*|string} Truncated email address
|
|
*/
|
|
export const truncateEmail = (email, maxLength = 24) => {
|
|
if (email === undefined || email === null) {
|
|
return '';
|
|
}
|
|
|
|
if (email.length <= maxLength) {
|
|
return email;
|
|
}
|
|
|
|
return email.slice(0, maxLength - 3) + '...';
|
|
};
|