centerTruncate.ts 505 B

1234567891011121314
  1. import {formatVersion} from 'sentry/utils/formatters';
  2. export function centerTruncate(value: string, maxLength: number = 20) {
  3. const divider = Math.floor(maxLength / 2);
  4. if (value?.length > maxLength) {
  5. return `${value.slice(0, divider)}\u2026${value.slice(value.length - divider)}`;
  6. }
  7. return value;
  8. }
  9. export function formatVersionAndCenterTruncate(value: string, maxLength?: number) {
  10. const formattedVersion = formatVersion(value);
  11. return centerTruncate(formattedVersion, maxLength);
  12. }