common-header-lib 0.0.21 → 0.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2637,23 +2637,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
2637
2637
 
2638
2638
  class SliceToTwoPipe {
2639
2639
  transform(textName) {
2640
- if (textName === null || textName === '') {
2640
+ if (!textName || typeof textName !== 'string') {
2641
2641
  return 'NA';
2642
2642
  }
2643
- textName = textName?.trim();
2644
- let result = '';
2645
- if (textName && textName.includes(' ')) {
2646
- let splitStringArr = textName.split(' ');
2647
- result =
2648
- splitStringArr[0][0] + splitStringArr[splitStringArr.length - 1][0];
2643
+ textName = textName.trim();
2644
+ let separator = textName.includes(' ') ? ' ' : '_';
2645
+ let splitStringArr = textName
2646
+ .split(separator)
2647
+ .filter((part) => part.length > 0);
2648
+ if (splitStringArr.length === 0) {
2649
+ return 'NA';
2649
2650
  }
2650
- else if (textName && textName.includes('_')) {
2651
- let splitStringArr = textName.split('_');
2651
+ let result = '';
2652
+ if (splitStringArr.length >= 2) {
2652
2653
  result =
2653
2654
  splitStringArr[0][0] + splitStringArr[splitStringArr.length - 1][0];
2654
2655
  }
2655
2656
  else {
2656
- result = textName[0] + textName[1];
2657
+ result = splitStringArr[0].slice(0, 2);
2657
2658
  }
2658
2659
  return result.toLocaleUpperCase();
2659
2660
  }