ac-sanitizer 5.0.1 → 5.1.0
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/CHANGELOG.md +14 -0
- package/README.md +2 -1
- package/index.js +9 -0
- package/package.json +3 -3
- package/test/tests/string.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
# [5.1.0](https://github.com/mmpro/ac-sanitizer/compare/v5.0.1..v5.1.0) (2025-09-10 10:32:21)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Feature
|
|
6
|
+
|
|
7
|
+
* **App:** Add option to convert a string with splitSpaceSeparated | MP | [d5974ea9286ceaa9cd6a3273e713ccf002cc7e7c](https://github.com/mmpro/ac-sanitizer/commit/d5974ea9286ceaa9cd6a3273e713ccf002cc7e7c)
|
|
8
|
+
Converts an URL encoded, space separated string into an array (e.g. for OAuth scopes)
|
|
9
|
+
Related issues:
|
|
10
|
+
### Chores
|
|
11
|
+
|
|
12
|
+
* **App:** Updated packages | MP | [3f832431642e3ae5705eb45f1c823ba5f29d9d50](https://github.com/mmpro/ac-sanitizer/commit/3f832431642e3ae5705eb45f1c823ba5f29d9d50)
|
|
13
|
+
Updated packages
|
|
14
|
+
Related issues:
|
|
1
15
|
|
|
2
16
|
## [5.0.1](https://github.com/mmpro/ac-sanitizer/compare/v5.0.0..v5.0.1) (2025-08-31 12:35:43)
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -80,6 +80,7 @@ integer | 60.1 -> 60 | Convert incoming number to integer - this way you can mak
|
|
|
80
80
|
string | Hello Developer -> Hello (with maxLength = 5) | Reduce string to max length
|
|
81
81
|
base64 | SGVsbG8= -> Hello | Convert base64 encoded string to UTF-8 string
|
|
82
82
|
iso-639 | { iso-639-2: 'tlh', translations: [] } -> tlh (with convert=iso-639-2) | Returns only the select property for the ISO-639 object
|
|
83
|
+
splitSpaceSeparated | user_read%20user_write -> ['user_read', 'user_write'] | Converts an URL encoded, space separated string into an array (e.g. for OAuth scopes)
|
|
83
84
|
|
|
84
85
|
|
|
85
86
|
## Available types
|
|
@@ -111,7 +112,7 @@ number | | Should no be used - use integer, long, short, floag
|
|
|
111
112
|
ratio | | x:y
|
|
112
113
|
rgb | | Check for valid RGB value (r,g,b) or (r%,g%, b%)
|
|
113
114
|
short | | 0 - 2^15
|
|
114
|
-
string | minLength (int), maxLength (int), ignoreCase | With ignoreCase=true enum checks are case insensitive (e.g. abc in ['ABC'] is valid)
|
|
115
|
+
string | minLength (int), maxLength (int), ignoreCase, splitSpaceSeparated | With ignoreCase=true enum checks are case insensitive (e.g. abc in ['ABC'] is valid)
|
|
115
116
|
url| protocols, require_tld, require_protocol | Default values: protocols ['http', 'https'], required_tld true, require_protocol true
|
|
116
117
|
|
|
117
118
|
# Examples
|
package/index.js
CHANGED
|
@@ -254,6 +254,15 @@ const sanitizer = function() {
|
|
|
254
254
|
}
|
|
255
255
|
else error = { message: fieldName + '_stringTooLong_maxLength' + field.maxLength }
|
|
256
256
|
}
|
|
257
|
+
if (_.get(field, 'convert') === 'splitSpaceSeparated') {
|
|
258
|
+
try {
|
|
259
|
+
const decoded = decodeURIComponent(value)
|
|
260
|
+
_.set(paramsToCheck, fieldName, decoded.split(' ').filter(Boolean))
|
|
261
|
+
}
|
|
262
|
+
catch(e) {
|
|
263
|
+
error = { message: fieldName + '_couldNotDecodeURI' }
|
|
264
|
+
}
|
|
265
|
+
}
|
|
257
266
|
}
|
|
258
267
|
else if (field.type === 'boolean') {
|
|
259
268
|
// GET params are strings -> try to make the boolean
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"author": "Mark Poepping (https://www.admiralcloud.com)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "admiralcloud/ac-sanitizer",
|
|
7
|
-
"version": "5.0
|
|
7
|
+
"version": "5.1.0",
|
|
8
8
|
"homepage": "https://www.admiralcloud.com",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"ac-countrylist": "^1.0.14",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"ac-semantic-release": "^0.4.7",
|
|
21
21
|
"c8": "^10.1.3",
|
|
22
|
-
"eslint": "^9.
|
|
23
|
-
"mocha": "^11.7.
|
|
22
|
+
"eslint": "^9.35.0",
|
|
23
|
+
"mocha": "^11.7.2"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"test": "mocha --reporter spec --bail",
|
package/test/tests/string.js
CHANGED
|
@@ -20,6 +20,7 @@ module.exports = {
|
|
|
20
20
|
{ name: 'Valid - uppercase vs lowercase', type: 'string', ignoreCase: true, value: 'ABC', enum: ['abc'], expected: 'ABC' },
|
|
21
21
|
{ name: 'Invalid - value too short', type: 'string', minLength: 5, value: 'ABC', error: 'string_stringTooShort_minLength5' },
|
|
22
22
|
{ name: 'Valid - value is longer than 5 chars', type: 'string', minLength: 5, value: 'ABCDEF', expected: 'ABCDEF' },
|
|
23
|
+
{ name: 'Valid - value is a URL encoded, space separated string', type: 'string', convert: 'splitSpaceSeparated', value: 'one%20two%20three', expected: ['one', 'two', 'three'] }
|
|
23
24
|
]
|
|
24
25
|
|
|
25
26
|
runValidationTests(baseTests, 'string', { equalityCheck: 'eql' })
|