@8ms/helpers 1.3.13 → 1.3.14
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/getDecoded.js +16 -3
- package/string/getString.js +2 -4
- package/string/getWithoutHtmlTags.js +2 -5
package/package.json
CHANGED
package/string/getDecoded.js
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const getString_1 = __importDefault(require("./getString"));
|
|
7
|
+
const unescape_1 = __importDefault(require("lodash/unescape"));
|
|
3
8
|
/**
|
|
4
9
|
* Convert escaped copy into unescaped.
|
|
5
10
|
* E.g. there's => there's
|
|
6
11
|
* https://stackoverflow.com/a/42182294/2664955
|
|
7
12
|
*/
|
|
8
13
|
const getDecoded = ({ input }) => {
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
let response = (0, getString_1.default)({ input });
|
|
15
|
+
// Only works if DOM exists
|
|
16
|
+
if (undefined !== document) {
|
|
17
|
+
let el = document.createElement("textarea");
|
|
18
|
+
el.innerHTML = response;
|
|
19
|
+
response = el.value;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
response = (0, unescape_1.default)(response);
|
|
23
|
+
}
|
|
24
|
+
return response;
|
|
12
25
|
};
|
|
13
26
|
exports.default = getDecoded;
|
package/string/getString.js
CHANGED
|
@@ -5,9 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const isArray_1 = __importDefault(require("lodash/isArray"));
|
|
7
7
|
const isDate_1 = __importDefault(require("lodash/isDate"));
|
|
8
|
-
const isNumber_1 = __importDefault(require("lodash/isNumber"));
|
|
9
8
|
const isObject_1 = __importDefault(require("lodash/isObject"));
|
|
10
|
-
const isString_1 = __importDefault(require("lodash/isString"));
|
|
11
9
|
const getNumber_1 = __importDefault(require("../date/getNumber"));
|
|
12
10
|
/**
|
|
13
11
|
* Convert into string.
|
|
@@ -15,11 +13,11 @@ const getNumber_1 = __importDefault(require("../date/getNumber"));
|
|
|
15
13
|
const getString = ({ input }) => {
|
|
16
14
|
let string = '';
|
|
17
15
|
// Already a string
|
|
18
|
-
if (
|
|
16
|
+
if ('string' === typeof input) {
|
|
19
17
|
string = input;
|
|
20
18
|
}
|
|
21
19
|
// Convert a number into a date
|
|
22
|
-
else if (
|
|
20
|
+
else if ('number' === typeof input) {
|
|
23
21
|
string = input.toString();
|
|
24
22
|
}
|
|
25
23
|
// Object or array to JSON
|
|
@@ -9,10 +9,7 @@ const getString_1 = __importDefault(require("./getString"));
|
|
|
9
9
|
* https://css-tricks.com/snippets/javascript/strip-html-tags-in-javascript/
|
|
10
10
|
*/
|
|
11
11
|
const getWithoutHtmlTags = ({ input }) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
input,
|
|
15
|
-
});
|
|
16
|
-
return inputString.replace(regexPattern, '');
|
|
12
|
+
return (0, getString_1.default)({ input })
|
|
13
|
+
.replace(/(<([^>]+)>)/gi, '');
|
|
17
14
|
};
|
|
18
15
|
exports.default = getWithoutHtmlTags;
|