one-click-accessibility/modules/settings/assets/js/helpers/popup-menu.js
Nirbhay Singh f274afbc04
[APP-1045] Add billing tab (#223)
* add: plan name and subscription link

* update: refactor my account menu

* update: move truncate email to a helper file

* update: simplify truncation logic
2025-03-17 13:19:43 +02:00

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) + '...';
};