itube-specs 0.0.461 → 0.0.462

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "itube-specs",
3
3
  "type": "module",
4
- "version": "0.0.461",
4
+ "version": "0.0.462",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "./types/index.d.ts",
7
7
  "scripts": {
@@ -6,9 +6,11 @@ export function groupCategoriesByFirstLetter(
6
6
  prop: string,
7
7
  nonLetterKey = 'POST',
8
8
  ): Record<string, Array<ICategoryCard>> {
9
- return items.reduce((acc, item) => {
10
- const firstLetter = (item[prop as keyof IRawCategoryCard] as string).charAt(0).toUpperCase();
11
- const key = /\p{L}/u.test(firstLetter) ? firstLetter : nonLetterKey;
9
+ const safeItems = Array.isArray(items) ? items : [];
10
+ return safeItems.reduce((acc, item) => {
11
+ const rawValue = String(item[prop as keyof IRawCategoryCard] ?? '').trim();
12
+ const firstLetter = rawValue.normalize().at(0)?.toUpperCase() ?? '';
13
+ const key = /^\p{L}$/u.test(firstLetter) ? firstLetter : nonLetterKey;
12
14
  if (!acc[key]) {
13
15
  acc[key] = [];
14
16
  }