fix: 🐛 update hidden secrets and flatten-nested-object logic (#2672)
This commit is contained in:
1 parent
2e94ebdb64
commit
cb895024e0
3 files changed
+7
-3
No files matched your search
@@ -18,8 +18,8 @@ export const flattenObject = (obj, result = {}, parentKey = '') => {
|
||||
if (typeOf(obj[key]) === 'object' && obj[key] !== null) {
|
||||
// Recursively flatten the object
|
||||
flattenObject(obj[key], result, `${parentKey}${key}.`);
|
||||
} else if (obj[key]) {
|
||||
// Only add to result if the value is not null
|
||||
} else if (obj[key] !== null && obj[key] !== '') {
|
||||
// Only add to result if the value is not null or an empty string
|
||||
result[`${parentKey}${key}`] = obj[key];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,12 +28,16 @@ module('Unit | Utility | flatten-nested-object', function () {
|
||||
d: {
|
||||
e: { f: { g: { h: '' } } },
|
||||
},
|
||||
i: 0,
|
||||
j: false,
|
||||
};
|
||||
const inputTwo = {
|
||||
d: { e: null },
|
||||
};
|
||||
const expectedResultOne = {
|
||||
'b.c': 2,
|
||||
i: 0,
|
||||
j: false,
|
||||
};
|
||||
const expectedResultTwo = {};
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ export default class HiddenSecretComponent extends Component {
|
||||
if (typeof this.args.secret === 'object' && this.args.secret !== null) {
|
||||
return JSON.stringify(this.args.secret, null, 2);
|
||||
} else {
|
||||
return this.args.secret;
|
||||
return this.args.secret.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user