@churchapps/apihelper 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.
@@ -1,5 +1,5 @@
1
1
  export declare class SlugHelper {
2
- static slugifyString(string: string, type: "urlPath" | "urlSlug", removeCharacters?: string[]): string;
2
+ static slugifyString(string: string, removeCharacters?: string[]): string;
3
3
  static numerifySlug(slug: string): string;
4
4
  }
5
5
  //# sourceMappingURL=SlugHelper.d.ts.map
@@ -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;CAqBjC"}
1
+ {"version":3,"file":"SlugHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/SlugHelper.ts"],"names":[],"mappings":"AACA,qBAAa,UAAU;IAErB,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,EAAE;IAYhE,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM;CAqBjC"}
@@ -1,15 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SlugHelper = void 0;
4
- const slug = require("slug");
5
4
  class SlugHelper {
6
- static slugifyString(string, type, removeCharacters) {
5
+ static slugifyString(string, removeCharacters) {
7
6
  const charactersToRemove = removeCharacters ? removeCharacters : ["for", "and", "nor", "but", "or", "yet", "so", "the", "a", "an"];
8
7
  const characStr = charactersToRemove.join("|");
9
- if (type === "urlPath") {
10
- slug.extend({ '/': '/' }); //To keep '/' in the url since it's a special character.
11
- }
12
- const initialSlug = slug(string, { remove: new RegExp('\\b(' + characStr + ')\\b', 'gi') });
8
+ const regex = new RegExp('\\b(' + characStr + ')\\b', 'gi');
9
+ const cleaned = string.replace(regex, '');
10
+ const initialSlug = cleaned.replace(/ /g, "-").toLowerCase();
13
11
  const verfiedSlug = this.numerifySlug(initialSlug);
14
12
  return verfiedSlug;
15
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SlugHelper.js","sourceRoot":"","sources":["../../src/helpers/SlugHelper.ts"],"names":[],"mappings":";;;AAAA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAE7B,MAAa,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,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,wDAAwD;QACrF,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,qCAAqC;IACrC,MAAM,CAAC,YAAY,CAAC,IAAY;QAC9B,IAAI,aAAa,GAAG,IAAI,CAAC;QACzB,MAAM,KAAK,GAAG,mBAA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C;QAE1C,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;QAC7D,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;QACnD,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,qCAAqC;IACrC,MAAM,CAAC,YAAY,CAAC,IAAY;QAC9B,IAAI,aAAa,GAAG,IAAI,CAAC;QACzB,MAAM,KAAK,GAAG,mBAAmB,CAAC;QAClC,MAAM,YAAY,GAAG,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAEhD,IAAI,YAAY,EAAE,CAAC;YACjB,YAAY,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;gBAC3B,IAAI,WAAW,GAAG,IAAI,CAAC;gBACvB,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;oBACf,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;oBAC7B,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBACzB,CAAC;gBACD,MAAM,cAAc,GAAG,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;gBAChE,aAAa,GAAG,cAAc,CAAC;YACjC,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,aAAa,CAAC;IACvB,CAAC;CAEF;AAnCD,gCAmCC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@churchapps/apihelper",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "description": "Library of helper functions not specific to any one ChurchApps project or framework.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -45,7 +45,6 @@
45
45
  "nodemailer-direct-transport": "^3.3.2",
46
46
  "react-ga4": "^2.1.0",
47
47
  "rrule": "^2.7.2",
48
- "slug": "^10.0.0",
49
48
  "winston": "^3.10.0",
50
49
  "winston-cloudwatch": "^6.2.0"
51
50
  },
@@ -1,14 +1,13 @@
1
- const slug = require("slug");
2
1
 
3
2
  export class SlugHelper {
4
3
 
5
- static slugifyString(string: string, type: "urlPath" | "urlSlug", removeCharacters?: string[]) {
4
+ static slugifyString(string: string, removeCharacters?: string[]) {
6
5
  const charactersToRemove = removeCharacters ? removeCharacters : ["for", "and", "nor", "but", "or", "yet", "so", "the", "a", "an"];
7
6
  const characStr = charactersToRemove.join("|");
8
- if (type === "urlPath") {
9
- slug.extend({ '/': '/' }); //To keep '/' in the url since it's a special character.
10
- }
11
- const initialSlug = slug(string, { remove: new RegExp('\\b(' + characStr + ')\\b', 'gi') });
7
+ const regex = new RegExp('\\b(' + characStr + ')\\b', 'gi')
8
+ const cleaned = string.replace(regex, '');
9
+
10
+ const initialSlug = cleaned.replace(/ /g, "-").toLowerCase();
12
11
  const verfiedSlug = this.numerifySlug(initialSlug);
13
12
  return verfiedSlug;
14
13
  }