[ICU-15403] Trim whitespace on storage buckets and host sets json attrs serializers (#2636)
* trim whitespace on json attrs in storage bucket serializer * add test for storage bucket serializer * move trimWhitespace check to application level * add trimWhitespace to preferred_endpoints attr * add conditional for string arr * trim whitespace on str arr * add check for null val * refactor, move logic * relocate comment * add unit test for application serializer
This commit is contained in:
1 parent
b287683a61
commit
e8cc22879f
7 files changed
+46
-5
No files matched your search
@@ -60,6 +60,18 @@ export default class ApplicationSerializer extends RESTSerializer {
|
||||
// Do not serialize `disabled` fields.
|
||||
// TODO: disabled is temporarily disabled
|
||||
if (key === 'disabled') delete json[key];
|
||||
|
||||
// Before we transform our json
|
||||
// Let's trim the values in the json obj
|
||||
// Currently, json values will only ever be a string or an array
|
||||
if (options.trimWhitespace && json[key]) {
|
||||
if (typeOf(json[key]) === 'array') {
|
||||
json[key] = json[key].map((str) => str.trim());
|
||||
} else if (typeOf(json[key] === 'string')) {
|
||||
json[key] = json[key].trim();
|
||||
}
|
||||
}
|
||||
|
||||
// Push nested attributes down into the attributes key
|
||||
if (options.isNestedAttribute && json[key] !== undefined) {
|
||||
if (!json.attributes) json.attributes = {};
|
||||
|
||||
Reference in new issue
Block a user