@churchapps/apphelper 0.5.10 → 0.5.11

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.
@@ -1 +1 @@
1
- {"version":3,"file":"SlugHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/SlugHelper.ts"],"names":[],"mappings":"AAEA,qBAAa,UAAU;IAErB,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,SAAS,EAAE,gBAAgB,CAAC,EAAE,MAAM,EAAE;IAY7F,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM;CAwBjC"}
1
+ {"version":3,"file":"SlugHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/SlugHelper.ts"],"names":[],"mappings":"AAEA,qBAAa,UAAU;IAErB,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,SAAS,EAAE,gBAAgB,CAAC,EAAE,MAAM,EAAE;IAY7F,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM;CAUjC"}
@@ -10,27 +10,13 @@ export class SlugHelper {
10
10
  const verfiedSlug = this.numerifySlug(initialSlug);
11
11
  return verfiedSlug;
12
12
  }
13
- //remove multiple numbers in sequence (e.g., 1-2-3 becomes 1), but allow standalone 1-2 digit numbers
13
+ //remove long sequences of single-digit numbers (e.g., 1-2-3-4 becomes 1), but preserve normal number patterns
14
14
  static numerifySlug(slug) {
15
15
  let initialString = slug;
16
- const regex = /\d+(?:-\d+)+|\d+/g;
17
- const matchedArray = initialString.match(regex);
18
- if (matchedArray) {
19
- matchedArray.forEach((data) => {
20
- const length = data.length;
21
- let splitResult = data;
22
- if (data.includes("-")) {
23
- splitResult = data.split("-")[0];
24
- }
25
- else if (length > 2) {
26
- splitResult = data.substring(0, 2);
27
- }
28
- if (splitResult !== data) {
29
- const replacedString = initialString.replace(data, splitResult);
30
- initialString = replacedString;
31
- }
32
- });
33
- }
16
+ // Only match sequences of 3+ single-digit numbers separated by hyphens (e.g., 1-2-3, 1-2-3-4)
17
+ // This avoids mangling things like chapter-verse references (6-11) or dates
18
+ const regex = /\b(\d)-(\d)-(\d)(?:-\d)*\b/g;
19
+ initialString = initialString.replace(regex, "$1");
34
20
  return initialString;
35
21
  }
36
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SlugHelper.js","sourceRoot":"","sources":["../../src/helpers/SlugHelper.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,OAAO,UAAU;IAErB,MAAM,CAAC,aAAa,CAAC,MAAc,EAAE,IAA2B,EAAE,gBAA2B;QAC3F,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QACnI,MAAM,SAAS,GAAG,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,IAAI,CAAC,MAAM,CAAC,EAAC,GAAG,EAAE,GAAG,EAAC,CAAC,CAAC,CAAC,wDAAwD;QACnF,CAAC;QACD,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,MAAM,CAAC,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5F,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;QACnD,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,qGAAqG;IACrG,MAAM,CAAC,YAAY,CAAC,IAAY;QAC9B,IAAI,aAAa,GAAG,IAAI,CAAC;QACzB,MAAM,KAAK,GAAG,mBAAmB,CAAC;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AC,GAAG,CAAC,CAAC;QAC/C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,IAAI,CAAC,MAAM,CAAC,EAAC,GAAG,EAAE,GAAG,EAAC,CAAC,CAAC,CAAC,wDAAwD;QACnF,CAAC;QACD,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,MAAM,CAAC,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5F,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;QACnD,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,8GAA8G;IAC9G,MAAM,CAAC,YAAY,CAAC,IAAY;QAC9B,IAAI,aAAa,GAAG,IAAI,CAAC;QACzB,8FAA8F;QAC9F,4EAA4E;QAC5E,MAAM,KAAK,GAAG,6BAA6B,CAAC;QAC5C,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAEnD,OAAO,aAAa,CAAC;IACvB,CAAC;CAEF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@churchapps/apphelper",
3
- "version": "0.5.10",
3
+ "version": "0.5.11",
4
4
  "description": "Library of helper functions for React and NextJS ChurchApps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,27 +13,13 @@ export class SlugHelper {
13
13
  return verfiedSlug;
14
14
  }
15
15
 
16
- //remove multiple numbers in sequence (e.g., 1-2-3 becomes 1), but allow standalone 1-2 digit numbers
16
+ //remove long sequences of single-digit numbers (e.g., 1-2-3-4 becomes 1), but preserve normal number patterns
17
17
  static numerifySlug(slug: string) {
18
18
  let initialString = slug;
19
- const regex = /\d+(?:-\d+)+|\d+/g;
20
- const matchedArray = initialString.match(regex);
21
-
22
- if (matchedArray) {
23
- matchedArray.forEach((data) => {
24
- const length = data.length;
25
- let splitResult = data;
26
- if (data.includes("-")) {
27
- splitResult = data.split("-")[0];
28
- } else if (length > 2) {
29
- splitResult = data.substring(0, 2);
30
- }
31
- if (splitResult !== data) {
32
- const replacedString = initialString.replace(data, splitResult);
33
- initialString = replacedString;
34
- }
35
- });
36
- }
19
+ // Only match sequences of 3+ single-digit numbers separated by hyphens (e.g., 1-2-3, 1-2-3-4)
20
+ // This avoids mangling things like chapter-verse references (6-11) or dates
21
+ const regex = /\b(\d)-(\d)-(\d)(?:-\d)*\b/g;
22
+ initialString = initialString.replace(regex, "$1");
37
23
 
38
24
  return initialString;
39
25
  }