fix(core): properties with similar names map to undefined #601
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As described in #527, in cases where there are two properties with same "suffix" (starting with the same part) like
StartDate
andStartDateTimeZone
it is assumed thatTimeZone
is actually nested property that needs to be flattened resulting in the property being undefined in the result.Where the shared suffix is being searched in source object, however, and that is my solution to the problem, it's not checked whether it's actually object and thus needs to be flattened. In the reference source object, primitive values are all undefined, but when there's nested objects, they're expanded as objects with their own properties. So this fix verifies, that the property to be flattened is an object.
I'm honestly wasn't sure if I should add it only at the two places I did or to just add it to the
hasProperty
function. I also didn't find any existing spec forgetFlatteningPaths
and as I'm not familiar with it in depth and don't know all the requirements, I'm not sure I'm up to writing all the other test cases..