@8ms/helpers 1.3.11 → 1.3.13

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": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "1.3.11",
4
+ "version": "1.3.13",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
@@ -14,5 +14,5 @@ type GetClean = {
14
14
  /**
15
15
  * Shorthand function to get a clean version of a string.
16
16
  */
17
- declare const getCleanString: ({ accents, decoded, htmlTags, input, lowercase, propercase, punctuation, trim, underscores, uppercase, whitespace }: GetClean) => string;
18
- export default getCleanString;
17
+ declare const getClean: ({ accents, decoded, htmlTags, input, lowercase, propercase, punctuation, trim, underscores, uppercase, whitespace }: GetClean) => string;
18
+ export default getClean;
@@ -14,7 +14,7 @@ const getDecoded_1 = __importDefault(require("./getDecoded"));
14
14
  /**
15
15
  * Shorthand function to get a clean version of a string.
16
16
  */
17
- const getCleanString = ({ accents, decoded, htmlTags, input, lowercase, propercase, punctuation, trim, underscores, uppercase, whitespace }) => {
17
+ const getClean = ({ accents, decoded, htmlTags, input, lowercase, propercase, punctuation, trim, underscores, uppercase, whitespace }) => {
18
18
  let response = (0, getString_1.default)({ input });
19
19
  if (decoded) {
20
20
  response = (0, getDecoded_1.default)({
@@ -62,4 +62,4 @@ const getCleanString = ({ accents, decoded, htmlTags, input, lowercase, properca
62
62
  }
63
63
  return response;
64
64
  };
65
- exports.default = getCleanString;
65
+ exports.default = getClean;
@@ -0,0 +1,11 @@
1
+ type GetClean = {
2
+ hash?: boolean;
3
+ input: string;
4
+ lowercase?: boolean;
5
+ parameter?: boolean;
6
+ };
7
+ /**
8
+ * Return a clean URL with a few options.
9
+ */
10
+ declare const getClean: ({ hash, input, lowercase, parameter }: GetClean) => string;
11
+ export default getClean;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const getWithoutParameter_1 = __importDefault(require("./getWithoutParameter"));
7
+ const getWithoutHash_1 = __importDefault(require("./getWithoutHash"));
8
+ /**
9
+ * Return a clean URL with a few options.
10
+ */
11
+ const getClean = ({ hash, input, lowercase, parameter }) => {
12
+ let response = input.trim();
13
+ if (parameter) {
14
+ response = (0, getWithoutParameter_1.default)({
15
+ input: response,
16
+ });
17
+ }
18
+ if (hash) {
19
+ response = (0, getWithoutHash_1.default)({
20
+ input: response,
21
+ });
22
+ }
23
+ if (lowercase) {
24
+ response = response.toLowerCase();
25
+ }
26
+ return response;
27
+ };
28
+ exports.default = getClean;
@@ -0,0 +1,8 @@
1
+ type GetWithoutHash = {
2
+ input: string;
3
+ };
4
+ /**
5
+ * Get a URL without the parameter query.
6
+ */
7
+ declare const getWithoutHash: ({ input }: GetWithoutHash) => string;
8
+ export default getWithoutHash;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Get a URL without the parameter query.
5
+ */
6
+ const getWithoutHash = ({ input }) => {
7
+ let response = input;
8
+ // Contains parameter query
9
+ if (-1 !== response.indexOf('#')) {
10
+ const split = response.split('#');
11
+ if (split.length > 1) {
12
+ response = split[0];
13
+ }
14
+ }
15
+ return response;
16
+ };
17
+ exports.default = getWithoutHash;
@@ -0,0 +1,8 @@
1
+ type GetWithoutParameter = {
2
+ input: string;
3
+ };
4
+ /**
5
+ * Get a URL without the parameter query.
6
+ */
7
+ declare const getWithoutParameter: ({ input }: GetWithoutParameter) => string;
8
+ export default getWithoutParameter;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Get a URL without the parameter query.
5
+ */
6
+ const getWithoutParameter = ({ input }) => {
7
+ let response = input;
8
+ // Contains parameter query
9
+ if (-1 !== response.indexOf('?')) {
10
+ const split = response.split('?');
11
+ if (split.length > 1) {
12
+ response = split[0];
13
+ }
14
+ }
15
+ return response;
16
+ };
17
+ exports.default = getWithoutParameter;