ag-common 0.0.7 → 0.0.8

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.
@@ -68,7 +68,7 @@ const getAndValidateToken = ({ tokenRaw, COGNITO_USER_POOL_ID, }) => __awaiter(v
68
68
  error: (0, api_1.returnCode)(403, 'auth failed'),
69
69
  };
70
70
  }
71
- token = tokenRaw.substr(tokenRaw.indexOf(' ') + 1);
71
+ token = tokenRaw.substring(tokenRaw.indexOf(' ') + 1);
72
72
  let subject;
73
73
  try {
74
74
  yield jwtVerify({ token, COGNITO_USER_POOL_ID });
@@ -6,4 +6,13 @@ export interface ISite {
6
6
  siteUrl: string;
7
7
  niceSiteUrl: string;
8
8
  }
9
+ /**
10
+ * removes protocol, and trailing slashes
11
+ */
9
12
  export declare const niceUrl: (siteUrl: string) => string | ISite;
13
+ /**
14
+ * string -> String
15
+ * @param str
16
+ * @returns
17
+ */
18
+ export declare function toTitleCase(str: string): string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.niceUrl = exports.truncate = exports.trim = exports.trimSide = exports.csvJSON = void 0;
3
+ exports.toTitleCase = exports.niceUrl = exports.truncate = exports.trim = exports.trimSide = exports.csvJSON = void 0;
4
4
  const csvJSON = (csv) => {
5
5
  const lines = csv.split('\n');
6
6
  const result = [];
@@ -44,15 +44,18 @@ function truncate(str, n, ellip) {
44
44
  if (!str) {
45
45
  return undefined;
46
46
  }
47
- return str.length > n ? str.substr(0, n - 1) + ellip : str;
47
+ return str.length > n ? str.substring(0, n - 1) + ellip : str;
48
48
  }
49
49
  exports.truncate = truncate;
50
+ /**
51
+ * removes protocol, and trailing slashes
52
+ */
50
53
  const niceUrl = (siteUrl) => {
51
54
  if (!siteUrl) {
52
55
  return siteUrl;
53
56
  }
54
57
  let niceSiteUrl = siteUrl
55
- .substr(siteUrl.indexOf(':') + 1)
58
+ .substring(siteUrl.indexOf(':') + 1)
56
59
  .replace('sc-domain:', '')
57
60
  .replace('https://', '')
58
61
  .replace('http://', '');
@@ -60,3 +63,15 @@ const niceUrl = (siteUrl) => {
60
63
  return { siteUrl, niceSiteUrl };
61
64
  };
62
65
  exports.niceUrl = niceUrl;
66
+ /**
67
+ * string -> String
68
+ * @param str
69
+ * @returns
70
+ */
71
+ function toTitleCase(str) {
72
+ if (!str) {
73
+ return str;
74
+ }
75
+ return str.replace(/\w\S*/g, (txt) => txt && txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase());
76
+ }
77
+ exports.toTitleCase = toTitleCase;
@@ -21,7 +21,7 @@ const LoginButton = ({ className, text = text_1.getstarted, invert, title, saveP
21
21
  const lp = loginPath(!savePath || typeof window === 'undefined'
22
22
  ? undefined
23
23
  : {
24
- redirect: window.location.href.substr(window.location.origin.length),
24
+ redirect: window.location.href.substring(window.location.origin.length),
25
25
  });
26
26
  return (react_1.default.createElement(Button_1.Button, { lang: lang, title: title, invert: invert, className: className, onKeyPress: () => __awaiter(void 0, void 0, void 0, function* () {
27
27
  yield pushPath(lp);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ag-common",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Andrei Gec <@andreigec> (https://gec.dev/)",