@@ -79,16 +79,13 @@ export class Scrubber {
7979 Object . keys ( dataCopy ) . forEach ( key => {
8080 let scrubberCurrentField = this . cfg . fields [ key ]
8181
82- if (
83- ! scrubberCurrentField &&
84- this . cfg . splitFields ?. [ key ] &&
85- parents &&
86- this . arrayContainsInOrder ( parents , this . cfg . splitFields [ key ] )
87- ) {
88- const splitFieldParentCfg : string [ ] = this . cfg . splitFields [ key ] || [ ]
89-
90- const recomposedKey = [ ...splitFieldParentCfg , key ] . join ( '.' )
91- scrubberCurrentField = this . cfg . fields [ recomposedKey ]
82+ if ( ! scrubberCurrentField && this . cfg . splitFields ?. [ key ] && parents ) {
83+ for ( const splitFieldParentCfg of this . cfg . splitFields [ key ] ! ) {
84+ if ( this . arrayContainsInOrder ( parents , splitFieldParentCfg ) ) {
85+ const recomposedKey = [ ...splitFieldParentCfg , key ] . join ( '.' )
86+ scrubberCurrentField = this . cfg . fields [ recomposedKey ]
87+ }
88+ }
9289 }
9390
9491 if ( ! scrubberCurrentField ) {
@@ -183,14 +180,16 @@ export class Scrubber {
183180 } )
184181 }
185182
186- private splitFields ( cfg : ScrubberConfig ) : StringMap < string [ ] > {
187- const output : StringMap < string [ ] > = { }
183+ private splitFields ( cfg : ScrubberConfig ) : StringMap < string [ ] [ ] > {
184+ const output : StringMap < string [ ] [ ] > = { }
188185 for ( const field of Object . keys ( cfg . fields ) ) {
189186 const splitField = field . split ( '.' )
190187
191188 if ( splitField . length > 1 ) {
192189 const key = splitField . pop ( ) !
193- output [ key ] = splitField
190+ // Support multiple keys with different parents
191+ output [ key ] ||= [ ]
192+ output [ key ] ! . push ( splitField )
194193 }
195194 }
196195 return output
0 commit comments