@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 +1 -1
- package/string/getClean.d.ts +2 -2
- package/string/getClean.js +2 -2
- package/util/getClean.d.ts +11 -0
- package/util/getClean.js +28 -0
- package/util/getWithoutHash.d.ts +8 -0
- package/util/getWithoutHash.js +17 -0
- package/util/getWithoutParameter.d.ts +8 -0
- package/util/getWithoutParameter.js +17 -0
package/package.json
CHANGED
package/string/getClean.d.ts
CHANGED
|
@@ -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
|
|
18
|
-
export default
|
|
17
|
+
declare const getClean: ({ accents, decoded, htmlTags, input, lowercase, propercase, punctuation, trim, underscores, uppercase, whitespace }: GetClean) => string;
|
|
18
|
+
export default getClean;
|
package/string/getClean.js
CHANGED
|
@@ -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
|
|
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 =
|
|
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;
|
package/util/getClean.js
ADDED
|
@@ -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,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,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;
|