hapijs / hoek

Node utilities shared among the extended hapi universe
Other
481 stars 171 forks source link

applyToDefaults() does not respect nullOverride when shallow is used #366

Closed kanongil closed 3 years ago

kanongil commented 3 years ago

Support plan

Context

What are you trying to achieve or the steps to reproduce?

Use method with nullOverride and shallow:

const defaults = { host: "localhost", port: 8000 };
const source = { host: null, port: 8080 };

Hoek.applyToDefaults(defaults, source, { nullOverride: true });
// Works - results in { host: null, port: 8080 }

Hoek.applyToDefaults(defaults, source, { nullOverride: true, shallow: [] });
// Fails - results in { host: "localhost", port: 8080 }

What was the result you got?

Any shallow changes the result when nullOverride: true.

What result did you expect?

Always respect nullOverride: true.