sanitized 1.2.3 → 1.2.5
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/README.md +7 -1
- package/index.js +17 -11
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -6,8 +6,14 @@ It accepts two params the first being the value to sanitize, and the second bein
|
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
|
+
```console
|
|
10
|
+
npm i sanitized
|
|
9
11
|
```
|
|
10
|
-
|
|
12
|
+
|
|
13
|
+
### Node v16 Support
|
|
14
|
+
|
|
15
|
+
```console
|
|
16
|
+
npm i sanitized@1.2.1
|
|
11
17
|
```
|
|
12
18
|
|
|
13
19
|
## Usage
|
package/index.js
CHANGED
|
@@ -10,21 +10,27 @@ if (!dompurify.sanitize) {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
function sanitized(dirty, dompurifyOption) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
for (let i = 0; i < clone.length; i++) {
|
|
17
|
-
clone[i] = sanitized(clone[i], dompurifyOption);
|
|
13
|
+
if (Array.isArray(dirty)) {
|
|
14
|
+
for (let i = 0; i < dirty.length; i++) {
|
|
15
|
+
dirty[i] = sanitized(dirty[i], dompurifyOption);
|
|
18
16
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
return dirty;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (typeof dirty === "object") {
|
|
21
|
+
for (const key in dirty) {
|
|
22
|
+
if (dirty.hasOwnProperty(key)) {
|
|
23
|
+
dirty[key] = sanitized(dirty[key], dompurifyOption);
|
|
24
|
+
}
|
|
22
25
|
}
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
return dirty;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (typeof dirty === "string") {
|
|
30
|
+
return he.decode(dompurify.sanitize(dirty, dompurifyOption));
|
|
25
31
|
}
|
|
26
32
|
|
|
27
|
-
return
|
|
33
|
+
return dirty;
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
module.exports = sanitized;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sanitized",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"description": "Recursive function that'll sanitize a string or ALL strings in a json input.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {},
|
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
],
|
|
16
16
|
"author": "Nameer Rizvi (https://github.com/nameer-rizvi)",
|
|
17
17
|
"license": "ISC",
|
|
18
|
-
"bugs":
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/nameer-rizvi/sanitized/issues"
|
|
20
|
+
},
|
|
19
21
|
"homepage": "https://github.com/nameer-rizvi/sanitized#readme",
|
|
20
22
|
"dependencies": {
|
|
21
23
|
"dompurify": "^3.1.4",
|