-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added recursive support for protected props #8
base: master
Are you sure you want to change the base?
Conversation
@@ -44,6 +44,9 @@ module.exports = function redactProtectedKeys(dictionary, blacklist) { | |||
throw new Error('Consistency violation: Unexpected bad usage in cleanseDictionary. Expected blacklist to be an array of strings, but got: '+util.inspect(blacklist,{depth:null})); | |||
}//>-• | |||
|
|||
if(_.isUndefined(recursive)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, imho if (....) {
because that is used elsewhere in this code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dan-omniscience yeah, if you wouldn't mind, that'd be helpful just for consistency
@tarlepp thanks, good catch
@@ -57,5 +60,18 @@ module.exports = function redactProtectedKeys(dictionary, blacklist) { | |||
|
|||
});//</_.each> | |||
|
|||
if(recursive){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
if(recursive){ | ||
// Loop over each top-level property and check if it is an object | ||
_.each(cleansedCopy, function(value, key){ | ||
if(_.isObject(cleansedCopy[key])){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
if(_.isObject(cleansedCopy[key])){ | ||
// Loop over each object inner property and redact any that are protected. | ||
_.each(cleansedCopy[key], function(value, PropName){ | ||
if(blacklist.indexOf(PropName) >= 0){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
I'm sorry but I didn't understand what exactly do you mean by your comments, can you be more specific so I could fix them? Thank you, |
|
@dan-omniscience Nice work! Here's some of the stuff going through my head:
So, after that consideration, and in the interest of keeping this hook lightweight: I think it might be best to add a new, configurable function to configure the default redaction behavior, instead of a e.g.
At load-time in the |
Hi,
I added support for recursive reduction of the props.
please review and merge if you like.
If you have any comments or suggestions I'll be happy to hear from you.
Thank you,
Dan